Switch from net/http to gin-gonic web framework
- 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
This commit is contained in:
parent
68285d861a
commit
2834657125
13 changed files with 474 additions and 812 deletions
|
|
@ -1,8 +1,7 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/imc-vibe/backend/internal/db"
|
||||
)
|
||||
|
||||
|
|
@ -21,12 +20,7 @@ type Stats struct {
|
|||
QueueSize int `json:"queueSize"`
|
||||
}
|
||||
|
||||
func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
Error(w, http.StatusMethodNotAllowed, "method not allowed")
|
||||
return
|
||||
}
|
||||
|
||||
func (h *StatsHandler) Get(c *gin.Context) {
|
||||
domains, err := h.db.GetAllDomains()
|
||||
if err != nil {
|
||||
domains = []db.DomainStats{}
|
||||
|
|
@ -49,5 +43,5 @@ func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) {
|
|||
QueueSize: 0,
|
||||
}
|
||||
|
||||
Success(w, stats)
|
||||
Success(c, stats)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue