feat: update framework

This commit is contained in:
Rogee
2024-11-29 15:03:47 +08:00
parent f7d95418a2
commit 391f217bd8
17 changed files with 368 additions and 132 deletions

21
backend/common/jwt/jwt.go Executable file
View File

@@ -0,0 +1,21 @@
package jwt
import (
"backend/providers/jwt"
"github.com/gofiber/fiber/v3"
)
func GetJwtToken(ctx fiber.Ctx) (string, error) {
headers, ok := ctx.GetReqHeaders()[jwt.HttpHeader]
if !ok {
return "", ctx.SendStatus(fiber.StatusUnauthorized)
}
if len(headers) == 0 {
return "", ctx.SendStatus(fiber.StatusUnauthorized)
}
token := headers[0]
token = token[len(jwt.TokenPrefix):]
return token, nil
}