add v2 API routes for admin and bug report management with rate limiting
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 43s

This commit is contained in:
Flavio Fois
2026-03-23 21:29:50 +01:00
parent 9cc0f3157c
commit 576ce0b1b5
9 changed files with 195 additions and 18 deletions

View File

@@ -1,7 +1,9 @@
package v1
import (
emlyMiddleware "emly-api-go/internal/middleware"
"net/http"
"time"
"emly-api-go/internal/handlers"
@@ -15,6 +17,15 @@ import (
func NewRouter(db *sqlx.DB) http.Handler {
r := chi.NewRouter()
rl := emlyMiddleware.NewRateLimiter(
5, // 5 req/sec per IP
10, // burst fino a 10
20, // ban dopo 20 violazioni
15*time.Minute, // ban di 15 minuti
)
r.Use(rl.Handler)
r.Use(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Server", "emly-api-go")