Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ApiErrorMiddleWare = func(ctx *fiber.Ctx, err error) error { logrus.WithError(err).Errorf("Unexpeceted error") if apiError, ok := err.(apierrors.Error); ok { return ctx.Status(apiError.StatusCode()).JSON(dto.ErrorResponse{ Message: apiError.Error(), }) } else { return ctx.Status(http.StatusInternalServerError).JSON(dto.ErrorResponse{ Message: fmt.Sprintf("Unexpected error: %s", err.Error()), }) } }
View Source
var AuthMiddlewareMiddleWare = func(ctx *fiber.Ctx) error { token := ctx.Get(authHeader) if token == "" { return apierrors.NewApiError("Missing authorization token", http.StatusUnauthorized) } valid, claim := security.GetClaim(token) if !valid { return apierrors.NewApiError("Invalid authorization token", http.StatusForbidden) } ctx.SetUserContext(security.AddClaimToContext(claim, ctx.UserContext())) return ctx.Next() }
View Source
var I18NMiddleware = func(ctx *fiber.Ctx) error { localize := i18n.GetLocalize(language.MustParse(ctx.Get(languageHeader, "en"))) ctx.SetUserContext(context.WithValue(ctx.UserContext(), "i18n", localize)) return ctx.Next() }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.