feat: initial router on main function

This commit is contained in:
ericprd
2025-02-22 16:15:38 +08:00
parent e57fa3ac6c
commit 3dd84e6932
9 changed files with 150 additions and 55 deletions
+12
View File
@@ -1,6 +1,8 @@
package utils
import (
"time"
jwtclaimenum "github.com/ardeman/project-legalgo-go/internal/enums/jwt"
timeutils "github.com/ardeman/project-legalgo-go/internal/utilities/time_utils"
"github.com/golang-jwt/jwt/v5"
@@ -25,3 +27,13 @@ func GenerateToken(options ...ClaimOption) (string, error) {
return token.SignedString(jwtSecret)
}
func GenerateToken2(username string) (string, error) {
now := timeutils.Now()
token := jwt.New(jwt.SigningMethodES256)
claims := token.Claims.(jwt.MapClaims)
claims["username"] = username
claims["exp"] = now.Add(time.Hour).Unix()
return token.SignedString(jwtSecret)
}