From f9acf99a28ad1e1074519508e72cbc47a7d88f40 Mon Sep 17 00:00:00 2001 From: gi8 Date: Thu, 21 Dec 2023 08:44:12 +0100 Subject: [PATCH] update doc strings --- cmd/root.go | 2 +- internal/server/auth.go | 14 +++++++++++++- internal/server/server.go | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index b36604b..219fa9f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -30,7 +30,7 @@ import ( ) const ( - version = "v0.0.16" + version = "v0.0.17" ) var ( diff --git a/internal/server/auth.go b/internal/server/auth.go index 7042ba3..9bab948 100644 --- a/internal/server/auth.go +++ b/internal/server/auth.go @@ -6,7 +6,19 @@ import ( "github.com/rs/zerolog/log" ) -// ApiTokenMiddleware checks for the presence and validity of the API token. +// ApiTokenMiddleware is a middleware function that checks for the presence and validity of the API token. +// +// Parameters: +// - next: http.HandlerFunc +// The next HTTP handler in the chain. +// - token: string +// The expected API token for authentication. +// +// Behavior: +// +// The middleware checks the 'X-API-Token' header in the incoming request against the provided token. +// If the header is missing or the token is invalid, it responds with an HTTP 401 Unauthorized status. +// If the token is valid, it calls the next handler in the chain. func ApiTokenMiddleware(next http.HandlerFunc, token string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { apiToken := r.Header.Get("X-API-Token") diff --git a/internal/server/server.go b/internal/server/server.go index 92a32d2..7667093 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -14,6 +14,7 @@ import ( "github.com/rs/zerolog/log" ) +// StaticFS is the embedded filesystem for static files. var StaticFS embed.FS // Run starts the HTTP server.