- Added gin-gonic v1.10.0 dependency - Refactored router.go: clean route groups with middleware chains - Refactored all handlers to use gin.Context instead of http.ResponseWriter/*http.Request - Simplified response helpers (JSON, Error, Success, Created, NoContent) - Clean auth middleware using Gin's c.Set() for context - Cleaner route definitions with path parameters (e.g., /domains/:name/users/:id) - Admin routes moved to /api/admin group with RequireAdmin middleware
34 lines
585 B
Go
34 lines
585 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/imc-vibe/backend/internal/mail"
|
|
)
|
|
|
|
type LogsHandler struct{}
|
|
|
|
func NewLogsHandler() *LogsHandler {
|
|
return &LogsHandler{}
|
|
}
|
|
|
|
func (h *LogsHandler) List(c *gin.Context) {
|
|
hours := 1
|
|
if h := c.Query("hours"); h != "" {
|
|
if n, err := strconv.Atoi(h); err == nil && n > 0 {
|
|
hours = n
|
|
}
|
|
}
|
|
|
|
filter := c.Query("filter")
|
|
|
|
entries, err := mail.GetLogs(hours, filter)
|
|
if err != nil {
|
|
Error(c, http.StatusServiceUnavailable, "log service not available")
|
|
return
|
|
}
|
|
|
|
Success(c, entries)
|
|
}
|