controller

package
v1.2210.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidNameTag = "name"
	ValidPortTag = "port"
	ValidCronTag = "cron"
)
View Source
var ValidateNameRegexpPattern = `^[a-zA-Z][a-zA-Z0-9\_\-]{0,59}$`

Functions

func BindAndValidateReq

func BindAndValidateReq(c echo.Context, i interface{}) error

func CanThisUserBeDisabled added in v1.2202.0

func CanThisUserBeDisabled(subjectUser, objectUser string) (err error)

subjectUser should be admin user.

func GetCurrentUser

func GetCurrentUser(c echo.Context) (*model.User, error)

func GetLimitAndOffset added in v1.2202.0

func GetLimitAndOffset(pageIndex, pageSize uint32) (limit, offset uint32)

func GetUserName

func GetUserName(c echo.Context) string

func JSONBaseErrorReq

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

func JSONNewDataExistErr added in v1.2202.0

func JSONNewDataExistErr(c echo.Context, format string, a ...interface{}) error

func JSONNewDataNotExistErr added in v1.2202.0

func JSONNewDataNotExistErr(c echo.Context, format string, a ...interface{}) error

func JSONNewNotImplementedErr added in v1.2202.0

func JSONNewNotImplementedErr(c echo.Context) error

func ReadFileContent

func ReadFileContent(c echo.Context, name string) (content string, fileExist bool, err error)

ReadFileContent read content from http body by name if file exist, the name is a http form data key, not file name.

func Validate

func Validate(i interface{}) error

func ValidateCron

func ValidateCron(fl validator.FieldLevel) bool

ValidateCron implements validator.Func

func ValidateName

func ValidateName(fl validator.FieldLevel) bool

ValidateName implements validator.Func

func ValidatePort

func ValidatePort(fl validator.FieldLevel) bool

ValidatePort implements validator.Func

Types

type BaseRes

type BaseRes struct {
	Code    int    `json:"code" example:"0"`
	Message string `json:"message" example:"ok"`
}

func NewBaseReq

func NewBaseReq(err error) BaseRes

type CustomValidator

type CustomValidator struct {
	// contains filtered or unexported fields
}

func NewCustomValidator

func NewCustomValidator() *CustomValidator

func (*CustomValidator) RegisterTranslation

func (cv *CustomValidator) RegisterTranslation(tag, enText, zhText string, params ...string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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