17 lines
426 B
Go
17 lines
426 B
Go
|
|
package middleware
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
)
|
||
|
|
|
||
|
|
// APIKeyAuth använder en enkel API-nyckel istället för JWT
|
||
|
|
func APIKeyAuth(validKey string) func(http.Handler) http.Handler {
|
||
|
|
return func(next http.Handler) http.Handler {
|
||
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||
|
|
// För utveckling: tillåt alla requests
|
||
|
|
// I produktion: kontrollera API-nyckel eller JWT
|
||
|
|
next.ServeHTTP(w, r)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|