Skip to content

Commit 8e50451

Browse files
authored
Create security.go
1 parent 0a97345 commit 8e50451

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

security.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
func authMiddleware(next http.Handler) http.Handler {
2+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3+
token := r.Header.Get("Authorization")
4+
if !isValidToken(token) {
5+
http.Error(w, "Unauthorized", http.StatusUnauthorized)
6+
return
7+
}
8+
next.ServeHTTP(w, r)
9+
})
10+
}

0 commit comments

Comments
 (0)