File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import (
30
30
)
31
31
32
32
const (
33
- version = "v0.0.16 "
33
+ version = "v0.0.17 "
34
34
)
35
35
36
36
var (
Original file line number Diff line number Diff line change @@ -6,7 +6,19 @@ import (
6
6
"github.com/rs/zerolog/log"
7
7
)
8
8
9
- // ApiTokenMiddleware checks for the presence and validity of the API token.
9
+ // ApiTokenMiddleware is a middleware function that checks for the presence and validity of the API token.
10
+ //
11
+ // Parameters:
12
+ // - next: http.HandlerFunc
13
+ // The next HTTP handler in the chain.
14
+ // - token: string
15
+ // The expected API token for authentication.
16
+ //
17
+ // Behavior:
18
+ //
19
+ // The middleware checks the 'X-API-Token' header in the incoming request against the provided token.
20
+ // If the header is missing or the token is invalid, it responds with an HTTP 401 Unauthorized status.
21
+ // If the token is valid, it calls the next handler in the chain.
10
22
func ApiTokenMiddleware (next http.HandlerFunc , token string ) http.HandlerFunc {
11
23
return func (w http.ResponseWriter , r * http.Request ) {
12
24
apiToken := r .Header .Get ("X-API-Token" )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
"github.com/rs/zerolog/log"
15
15
)
16
16
17
+ // StaticFS is the embedded filesystem for static files.
17
18
var StaticFS embed.FS
18
19
19
20
// Run starts the HTTP server.
You can’t perform that action at this time.
0 commit comments