Documentation ¶
Index ¶
- Constants
- func ErrorNormalizerMiddleware() echo.MiddlewareFunc
- func FromApi(ctx echo.Context) context.Context
- func ParseParamId(c echo.Context, name string) (ids.ID, error)
- func RealUserFromContext(c echo.Context) (xuser.User, bool)
- func UserFromContext(c echo.Context) (user xuser.User, found bool)
- func UserFromContextOrError(c echo.Context) (user xuser.User, err error)
- type HTTPStatusProvider
Constants ¶
const ImpersonatingUserKeyName = "ImpersonatingUser"
const UserCtxKey = "x-user"
Variables ¶
This section is empty.
Functions ¶
func ErrorNormalizerMiddleware ¶ added in v0.27.0
func ErrorNormalizerMiddleware() echo.MiddlewareFunc
ErrorNormalizerMiddleware is a middleware that convert general errors to HTTPError. This middleware should be after the logger middleware. The conversion should be performed by the CustomErrorHandler but the logger middleware will not log the real status code if it is not a HTTPError.
func FromApi ¶
FromApi returns a context.Context that wraps the echo.Context. The stored values in the echo.Context are accessible via the context.Context.
func RealUserFromContext ¶
RealUserFromContext returns the real authenticated user. If user was impersonated, it returns the impersonating user. If not, the same user in context is returned.
func UserFromContext ¶
UserFromContext returns the authenticated user from the context. If the user does not exist, or it is an invalid struct, found will be false.
func UserFromContextOrError ¶
UserFromContextOrError returns the authenticated user from the context. If the user does not exist, or it is an invalid struct, returns an error.
Types ¶
type HTTPStatusProvider ¶ added in v0.27.0
type HTTPStatusProvider interface {
HTTPStatus() int
}