solidarity transport updates

This commit is contained in:
Arnaud Delcasse
2025-09-09 05:47:56 +02:00
parent 95b60ea737
commit 9ab7b66b68
40 changed files with 3240 additions and 601 deletions

View File

@@ -0,0 +1,19 @@
package protectapi
import (
"net/http"
"github.com/rs/zerolog/log"
)
func ApiKey(apiKey string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if apiKey == "" || r.Header.Get("X_API_KEY") != apiKey {
log.Info().Msg("call to api not allowed")
w.WriteHeader(http.StatusForbidden)
}
next.ServeHTTP(w, r)
})
}
}