utils

package
v0.0.0-...-f47b430 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAndValidate

func BindAndValidate(ctx *fiber.Ctx, d any) error

BindAndValidate binds request payload and validates the requested payload.

func GetFromReqBody

func GetFromReqBody[T any](ctx *fiber.Ctx) (T, error)

GetFromReqBody reads data from ctx.Locals("body") which was set by the BindJson middleware earlier

func GetUserFromCtx

func GetUserFromCtx(ctx *fiber.Ctx) *models.User

GetUserFromCtx extracts requested user from ctx and returns it. The user will be assigned to context from middleware

Types

type Response

type Response struct {
	Status  status  `json:"status"`
	Message *string `json:"message,omitempty"`
	Data    any     `json:"data,omitempty"`
}

func NewError

func NewError(err error) *Response

func NewSuccessResp

func NewSuccessResp(data any, messages ...string) *Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL