From e0dee4d45cd497fd53136797e69c6aa650924232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Mon, 26 May 2025 12:40:27 +0200 Subject: [PATCH] Add files via upload --- auth.go | 4 ++-- main.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth.go b/auth.go index 89bd375..26a9ebf 100644 --- a/auth.go +++ b/auth.go @@ -97,7 +97,7 @@ func verifyToken(tokenString string) (*Claims, error) { } // AuthMiddleware verifies the JWT token in the Authorization header -func authMiddleware(next http.Handler) http.Handler { +func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Get token from Authorization header authHeader := r.Header.Get("Authorization") @@ -126,7 +126,7 @@ func authMiddleware(next http.Handler) http.Handler { }) } -func loginHandler(w http.ResponseWriter, r *http.Request) { +func LoginHandler(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, `{"error":"Method not allowed"}`, http.StatusMethodNotAllowed) return diff --git a/main.go b/main.go index 930063e..dfa74e1 100644 --- a/main.go +++ b/main.go @@ -54,11 +54,11 @@ func main() { }).Methods("GET", "OPTIONS") // Authentication routes - r.HandleFunc("/api/login", loginHandler).Methods("POST", "OPTIONS") + r.HandleFunc("/api/login", LoginHandler).Methods("POST", "OPTIONS") // Protected API routes api := r.PathPrefix("/api").Subrouter() - api.Use(authMiddleware) + api.Use(AuthMiddleware) api.HandleFunc("/submit", handleSubmit).Methods("POST") // Admin routes