feat: more reorganisation and keys endpoint

This commit is contained in:
DaanSelen
2026-04-23 16:51:18 +02:00
parent c3aac38089
commit 417cecf43f
10 changed files with 131 additions and 95 deletions
+5 -2
View File
@@ -11,6 +11,8 @@ import (
)
func SlogMiddleware(logger *slog.Logger) gin.HandlerFunc {
// Make a slog-looking logger, inspired by the gin docs themself
// JSON logger: https://gin-gonic.com/en/docs/logging/structured-logging/
return func(c *gin.Context) {
start := time.Now()
path := c.Request.URL.Path
@@ -47,6 +49,8 @@ func AuthMiddleware() gin.HandlerFunc {
}
headerParts := strings.Split(authorizationHeader, " ")
// The header must be a specific format, 0 being the bearer text and 1 being the token itself, making it 2 pieces total
// In the following if statement we verify both parts if the part after Bearer is empty its only 1 part for example
if len(headerParts) != 2 || headerParts[0] != "Bearer" {
c.AbortWithStatusJSON(http.StatusUnauthorized, response.BasicResponse{
Msg: "Authorization header is invalid",
@@ -54,7 +58,6 @@ func AuthMiddleware() gin.HandlerFunc {
return
}
givenKey := headerParts[1]
slog.Info(givenKey)
//givenKey := headerParts[1]
}
}