Documentation
¶
Index ¶
- Constants
- func BadRequest(c *fiber.Ctx, body interface{}) error
- func Conflict(c *fiber.Ctx, body interface{}) error
- func Created(c *fiber.Ctx, body interface{}) error
- func ErrConflict(c *fiber.Ctx, msg ...string) error
- func ErrForbidden(c *fiber.Ctx) error
- func ErrGone(c *fiber.Ctx) error
- func ErrInternal(c *fiber.Ctx, err error) error
- func ErrMethodNotAllowed(c *fiber.Ctx) error
- func ErrNotFound(c *fiber.Ctx) error
- func ErrToManyRequests(c *fiber.Ctx) error
- func ErrUnauthorized(c *fiber.Ctx) error
- func Int64(c *fiber.Ctx, key string) (int64, error)
- func Json(errNotFound error) fiber.Handler
- func Ok(c *fiber.Ctx, body interface{}) error
- func OkErr(c *fiber.Ctx, err error) error
- func Paginated(next func(*fiber.Ctx, Pagination) error, params ...int64) fiber.Handler
- func ParseData[T any](r io.Reader) (*T, error)
- func Parser[T any](next func(*fiber.Ctx, *T) error) fiber.Handler
- func Raw(c *fiber.Ctx, status int, body interface{}) error
- func Serve(route Route, config ServerConfig) error
- func Start()
- func Translator() ut.Translator
- func Validator() *validator.Validate
- type Body
- type Entries
- type Option
- type Pagination
- type Response
- type Route
- type ServerConfig
- type Status
Constants ¶
const ContentType = "application/json; charset=utf-8"
const DefaultMaxOffset = int64(math.MaxInt16)
const DefaultMaxSize = int64(100)
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(c *fiber.Ctx, body interface{}) error
returns a 400 BadRequest response with the given body
func Created ¶
func Created(c *fiber.Ctx, body interface{}) error
returns a 201 Created response with the given body
func ErrConflict ¶
func ErrForbidden ¶
func ErrForbidden(c *fiber.Ctx) error
func ErrInternal ¶
func ErrMethodNotAllowed ¶
func ErrMethodNotAllowed(c *fiber.Ctx) error
func ErrNotFound ¶
func ErrNotFound(c *fiber.Ctx) error
func ErrToManyRequests ¶
func ErrToManyRequests(c *fiber.Ctx) error
func ErrUnauthorized ¶
func ErrUnauthorized(c *fiber.Ctx) error
func Ok ¶
func Ok(c *fiber.Ctx, body interface{}) error
returns a 200 OK response with the given body
func OkErr ¶
returns a 200 OK response with an empty body or the given error if the error is not nil
func Paginated ¶
func Paginated(next func(*fiber.Ctx, Pagination) error, params ...int64) fiber.Handler
Paginated is a middleware that parses the limit and offset parameters from the query string. takes two optional parameters: the maximum limit and the maximum offset.
Only GET requests are allowed to use this middleware
func Parser ¶
Parser is a middleware that parse the body of the request and validates it. An invalid validation returns a 400 Bad Request with a JSON body containing the validation errors. Here is an example response: {"status":"fail","data":{"validation":{"name":"name is a required field"}}}
func Serve ¶
func Serve(route Route, config ServerConfig) error
Serve starts an instance of the http server.
func Translator ¶
func Translator() ut.Translator
Types ¶
type Option ¶
type Option func(*ServerConfig)