Documentation
¶
Index ¶
- Variables
- func Handler[T Env](routeName string, loadEnv func(ctx *fasthttp.RequestCtx) (T, Response, error), ...) func(ctx *fasthttp.RequestCtx)
- func NoEnvHandler(routeName string, next func(ctx *fasthttp.RequestCtx) (Response, error)) func(ctx *fasthttp.RequestCtx)
- type DynamicResponse
- type Env
- type ErrorIdResponse
- type Response
- type StaticResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var (
InvalidJSON = StaticError(400, utils.RES_INVALID_JSON_PAYLOAD, "invalid json payload")
)
View Source
var (
OkLogData = log.NewField().
Int("status", 200).
Finalize()
)
Functions ¶
func Handler ¶
func Handler[T Env](routeName string, loadEnv func(ctx *fasthttp.RequestCtx) (T, Response, error), next func(ctx *fasthttp.RequestCtx, env T) (Response, error)) func(ctx *fasthttp.RequestCtx)
func NoEnvHandler ¶
func NoEnvHandler(routeName string, next func(ctx *fasthttp.RequestCtx) (Response, error)) func(ctx *fasthttp.RequestCtx)
Types ¶
type DynamicResponse ¶
type DynamicResponse struct {
// contains filtered or unexported fields
}
body isn't known until runtime, but we know the status and code and can put those in logData
func OkBytes ¶
func OkBytes(body []byte) DynamicResponse
func Validation ¶
func Validation(validator *validation.Result) DynamicResponse
func (DynamicResponse) EnhanceLog ¶
func (r DynamicResponse) EnhanceLog(logger log.Logger) log.Logger
func (DynamicResponse) Write ¶
func (r DynamicResponse) Write(conn *fasthttp.RequestCtx)
type ErrorIdResponse ¶
type ErrorIdResponse struct {
// contains filtered or unexported fields
}
func (ErrorIdResponse) EnhanceLog ¶
func (r ErrorIdResponse) EnhanceLog(logger log.Logger) log.Logger
func (ErrorIdResponse) Write ¶
func (r ErrorIdResponse) Write(conn *fasthttp.RequestCtx)
type Response ¶
type Response interface { // return logger for chaining EnhanceLog(logger log.Logger) log.Logger Write(conn *fasthttp.RequestCtx) }
func SerializationError ¶
func SerializationError() Response
func ServerError ¶
func ServerError() Response
type StaticResponse ¶
type StaticResponse struct {
// contains filtered or unexported fields
}
We know the status/body/logData upfront (lets us optimize EnhanceLog)
func StaticError ¶
func StaticError(status int, code int, error string) StaticResponse
func StaticNotFound ¶
func StaticNotFound(code int) StaticResponse
func (StaticResponse) EnhanceLog ¶
func (r StaticResponse) EnhanceLog(logger log.Logger) log.Logger
func (StaticResponse) Write ¶
func (r StaticResponse) Write(conn *fasthttp.RequestCtx)
Click to show internal directories.
Click to hide internal directories.