Documentation ¶
Index ¶
- Constants
- func BindAndValidate(c echo.Context, v runtime.Validatable, vs ...runtime.Validatable) error
- func BindAndValidateBody(c echo.Context, v runtime.Validatable) error
- func BindAndValidatePathAndQueryParams(c echo.Context, v runtime.Validatable) error
- func BindAndValidatePathParams(c echo.Context, v runtime.Validatable) error
- func BindAndValidateQueryParams(c echo.Context, v runtime.Validatable) error
- func ContainsAllString(slice []string, sub ...string) bool
- func ContainsString(slice []string, s string) bool
- func DisableLogger(ctx context.Context, shouldDisable bool) context.Context
- func GenerateJwt(email string, exp time.Duration) (sql.NullString, error)
- func GetEnv(key string, defaultVal string) string
- func GetEnvAsBool(key string, defaultVal bool) bool
- func GetEnvAsInt(key string, defaultVal int) int
- func GetEnvAsStringArr(key string, defaultVal []string, separator ...string) []string
- func GetEnvAsStringArrTrimmed(key string, defaultVal []string, separator ...string) []string
- func GetEnvAsURL(key string, defaultVal string) *url.URL
- func GetEnvAsUint32(key string, defaultVal uint32) uint32
- func GetEnvAsUint8(key string, defaultVal uint8) uint8
- func GetEnvEnum(key string, defaultVal string, allowedValues []string) string
- func GetProjectRootDir() string
- func LogFromContext(ctx context.Context) *zerolog.Logger
- func LogFromEchoContext(c echo.Context) *zerolog.Logger
- func LogLevelFromString(s string) zerolog.Level
- func ParseFileUpload(c echo.Context, formNameFile string, allowedMIMETypes []string) (*multipart.FileHeader, multipart.File, *mimetype.MIME, error)
- func RequestIDFromContext(ctx context.Context) (string, error)
- func ShouldDisableLogger(ctx context.Context) bool
- func UniqueString(slice []string) []string
- func ValidateAndReturn(c echo.Context, code int, v runtime.Validatable) error
- func VerifyJWT(tokenString string) (jwt.MapClaims, error)
Constants ¶
const ( CTXKeyUser contextKey = "user" CTXKeyAccessToken contextKey = "access_token" CTXKeyRequestID contextKey = "request_id" CTXKeyDisableLogger contextKey = "disable_logger" CTXKeyCacheControl contextKey = "cache_control" )
const ( HTTPHeaderCacheControl = "Cache-Control" TokenTypeBearer = "Bearer" )
Variables ¶
This section is empty.
Functions ¶
func BindAndValidate ¶
func BindAndValidate(c echo.Context, v runtime.Validatable, vs ...runtime.Validatable) error
BindAndValidate binds the request, parsing path+query+body and validating these structs.
func BindAndValidateBody ¶
func BindAndValidateBody(c echo.Context, v runtime.Validatable) error
BindAndValidateBody binds the request body and performs validation.
func BindAndValidatePathAndQueryParams ¶
func BindAndValidatePathAndQueryParams(c echo.Context, v runtime.Validatable) error
BindAndValidatePathAndQueryParams binds path and query params and performs validation.
func BindAndValidatePathParams ¶
func BindAndValidatePathParams(c echo.Context, v runtime.Validatable) error
BindAndValidatePathParams binds path params and performs validation.
func BindAndValidateQueryParams ¶
func BindAndValidateQueryParams(c echo.Context, v runtime.Validatable) error
BindAndValidateQueryParams binds query params and performs validation.
func ContainsAllString ¶
ContainsAllString checks whether the given string slice contains all strings provided.
func ContainsString ¶
ContainsString checks whether the given string slice contains the string provided.
func GenerateJwt ¶
func GetEnvAsBool ¶
func GetEnvAsInt ¶
func GetEnvAsStringArr ¶
GetEnvAsStringArr reads ENV and returns the values split by separator.
func GetEnvAsStringArrTrimmed ¶
GetEnvAsStringArrTrimmed reads ENV and returns the whitespace trimmed values split by separator.
func GetEnvAsUint32 ¶
func GetEnvAsUint8 ¶
func GetProjectRootDir ¶
func GetProjectRootDir() string
GetProjectRootDir returns the path as string to the project_root for a **running application**.
func LogFromContext ¶
LogFromContext returns a request-specific zerolog instance using the provided context. The returned logger will have the request ID as well as some other value predefined. If no logger is associated with the context provided, the global zerolog instance will be returned instead - this function will _always_ return a valid (enabled) logger. Should you ever need to force a disabled logger for a context, use `util.DisableLogger(ctx, true)` and pass the context returned to other code/`LogFromContext`.
func LogFromEchoContext ¶
LogFromEchoContext returns a request-specific zerolog instance using the echo.Context of the request. The returned logger will have the request ID as well as some other value predefined.
func LogLevelFromString ¶
func ParseFileUpload ¶
func ParseFileUpload(c echo.Context, formNameFile string, allowedMIMETypes []string) (*multipart.FileHeader, multipart.File, *mimetype.MIME, error)
ParseFileUpload handles file uploads and validates MIME types.
func ShouldDisableLogger ¶
func UniqueString ¶
UniqueString takes the string slice provided and returns a new slice with all duplicates removed.
func ValidateAndReturn ¶
func ValidateAndReturn(c echo.Context, code int, v runtime.Validatable) error
ValidateAndReturn returns the provided data as a JSON response after performing payload validation.
Types ¶
This section is empty.