- Binary name: imc-vibe -> imc - Go module: github.com/imc-vibe/backend -> github.com/imc/backend - JWT issuer: imc-vibe -> imc - UI labels: IMC Vibe -> IMC - Update all imports and comments
34 lines
580 B
Go
34 lines
580 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/imc/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)
|
|
}
|