web

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_CONTEXT_KEY = "is_app_context"
	LOCALIZER_KEY   = "is_localizer"
)
View Source
const (
	VALIDATION_EMAIL               = "inkEmail"
	VALIDATION_NOT_ALL_FIELDS_ZERO = "notAllFieldsZero"
)

Variables

This section is empty.

Functions

func HandlerAdapter

func HandlerAdapter(handler HandlerFunc) gin.HandlerFunc

func SetupRouter

func SetupRouter(appCtx *app.AppContext) (router *gin.Engine, gApi *gin.RouterGroup)

func SetupRouterWith

func SetupRouterWith(appCtx *app.AppContext, opts *app.Options) *gin.Engine

func ValidationEmail

func ValidationEmail(fl validator.FieldLevel) bool

func ValidationNotAllFieldsZero

func ValidationNotAllFieldsZero(sl validator.StructLevel)

Types

type ClientError

type ClientError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func (*ClientError) Error

func (e *ClientError) Error() string

type Context

type Context struct {
	*gin.Context
}

func (*Context) AbortWithClientError

func (c *Context) AbortWithClientError(err error)

func (*Context) AbortWithForbidden

func (c *Context) AbortWithForbidden(err error)

func (*Context) AbortWithServerError

func (c *Context) AbortWithServerError(err error)

func (*Context) AbortWithUnauthorized

func (c *Context) AbortWithUnauthorized(err error)

func (*Context) AppContext

func (c *Context) AppContext() *app.AppContext

func (*Context) Empty

func (c *Context) Empty()

func (*Context) Localizer

func (c *Context) Localizer() *libI18n.Localizer

func (*Context) Response

func (c *Context) Response(res any)

func (*Context) Translate

func (c *Context) Translate(messageID string) string

type HandlerFunc

type HandlerFunc func(*Context)

type PagingRequest

type PagingRequest struct {
	Offset int `form:"offset" binding:"min=0"`
	Limit  int `form:"limit" binding:"required,min=1,max=100"`
}

type PagingResponse

type PagingResponse[T any] struct {
	Offset int `json:"offset"`
	Limit  int `json:"limit"`
	Total  int `json:"total"`
	Items  []T `json:"items,omitempty"`
}

type Response

type Response struct {
	Id        int        `json:"id,omitempty"`
	CreatedAt *time.Time `json:"createdAt,omitempty"`
	UpdatedAt *time.Time `json:"updatedAt,omitempty"`
}

Jump to

Keyboard shortcuts

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