routeutils

package
v0.0.0-...-32983dc Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorMessageServiceUnavailable = "Service temporarily unavailable"

Variables

This section is empty.

Functions

func BuildPaginatedResult

func BuildPaginatedResult[T any](list T, skip int64, take int64, totalRecords int64) viewmodel.PaginatedResult[T]

BuildPaginatedResult is a function that builds a paginated result based on the given parameters. It takes a list of type T, the number of records to skip, the number of records to take, and the total number of records available. It returns a PaginatedResult of type T, which contains the paginated list and pagination information.

func GetAndValidateParam

func GetAndValidateParam(c echo.Context, paramName string, errorMessage string) (paramValue string, err error)

GetAndValidateParam gets the param value and validates it, returning a validation error in case it's invalid

func GetContext

func GetContext(c echo.Context) (ctx context.Context)

func GetPagingParams

func GetPagingParams(c echo.Context, pageParameter, quantityParameter string) (take int64, skip int64)

GetPagingParams gets the standard paging params from the URL, returning how much data to take and skip

func GetTakeSkipFromPageQuantity

func GetTakeSkipFromPageQuantity(page, quantity int64) (take, skip int64)

func HandleAPIError

func HandleAPIError(c echo.Context, errorToHandle error) (err error)

func ResponseAPIError

func ResponseAPIError(c echo.Context, status int, message string, err string, causes interface{}) error

func ResponseAPIOk

func ResponseAPIOk(c echo.Context, data interface{}) error

func ResponseBadRequestError

func ResponseBadRequestError(c echo.Context, err error) error

func ResponseCreated

func ResponseCreated(c echo.Context) error

func ResponseNoContent

func ResponseNoContent(c echo.Context) error

func ResponseNotFoundError

func ResponseNotFoundError(c echo.Context, err error) error

func ResponseUnauthorizedError

func ResponseUnauthorizedError(c echo.Context, err error) error

Types

type EchoGroups

type EchoGroups struct {
	// AppGroup is the group for public routes
	AppGroup models.EchoGroup
	// PrivateGroup is the group for routes that need to be authenticated (login required)
	PrivateGroup models.EchoGroup
}

EchoGroups is the struct that holds the echo groups for the routes

type IRoute

type IRoute interface {
	RegisterRoutes(groups *EchoGroups)
}

IRoute interface for register routes

Jump to

Keyboard shortcuts

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