package jwt import ( "clapclap/internal/apperr" "clapclap/internal/utils" "net/http" "github.com/gin-gonic/gin" ) type Issuer struct { mint func(*gin.Context) (string, error) // IMPORTANT MUST CALL c.Next() send utils.Sender } func (i *Issuer) Default() { i.mint = MintFromCtx i.send = utils.SendStringAsBody() } func (i *Issuer) Cookie(config http.Cookie) { i.mint = MintFromCtx i.send = utils.SendStringAsCookie(config) } func (i Issuer) Issue(c *gin.Context) { tkn, err := i.mint(c) if err != nil { apperr.AbortWithError(c, apperr.NewInternalServerError(err, "Failed to mint authentication token")) return } i.send(c, tkn) }