common

package
v2.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTokenInvalidFromDate = fmt.Errorf("token is invalid starting from a certain date")
View Source
var ErrTokenNotProvided = fmt.Errorf("token not provided")
View Source
var ErrTokenUserNotFound = fmt.Errorf("user not found")

Functions

func AdminGuard

func AdminGuard(app *core.App, handler fiber.Handler) fiber.Handler

func CheckIsAdminReq

func CheckIsAdminReq(app *core.App, c *fiber.Ctx) bool

func CheckSiteExist

func CheckSiteExist(app *core.App, c *fiber.Ctx, siteName string) (entity.CookedSite, bool, error)

func ErrorHandler

func ErrorHandler(ctx *fiber.Ctx, err error) error

func GetJwtDataByReq

func GetJwtDataByReq(app *core.App, c *fiber.Ctx) (jwtCustomClaims, error)

func GetLimiter

func GetLimiter(c *fiber.Ctx) (lmt *limiter.Limiter, err error)

func GetTokenByReq

func GetTokenByReq(c *fiber.Ctx) string

func GetUserByReq

func GetUserByReq(app *core.App, c *fiber.Ctx) (entity.User, error)

func LimiterGuard

func LimiterGuard(app *core.App, handler fiber.Handler) fiber.Handler

func LogWithHttpInfo

func LogWithHttpInfo(c *fiber.Ctx, logFn func(l *zap.SugaredLogger))

func LoginGetUserToken

func LoginGetUserToken(user entity.User, key string, ttl int) (string, error)

func LoginGuard

func LoginGuard(app *core.App, handler func(*fiber.Ctx, entity.User) error) fiber.Handler

func NewCaptchaChecker

func NewCaptchaChecker(app *core.App, c *fiber.Ctx) captcha.Checker

func ParamsDecode

func ParamsDecode(c *fiber.Ctx, destParams interface{}) (isContinue bool, resp error)

func RespData

func RespData(c *fiber.Ctx, data interface{}) error

RespData is just response data

func RespError

func RespError(c *fiber.Ctx, code int, msg string, data ...Map) error

RespError is just response error

func RespSuccess

func RespSuccess(c *fiber.Ctx, msg ...string) error

RespSuccess is just response success

func ValidateRequired

func ValidateRequired(c *fiber.Ctx, destParams interface{}) (isContinue bool, resp error)

Types

type ApiVersionData

type ApiVersionData struct {
	App        string `json:"app"`
	Version    string `json:"version"`
	CommitHash string `json:"commit_hash"`
}

func GetApiVersionDataMap

func GetApiVersionDataMap() ApiVersionData

type ConfData

type ConfData struct {
	FrontendConf Map            `json:"frontend_conf"`
	Version      ApiVersionData `json:"version"`
}

func GetApiPublicConfDataMap

func GetApiPublicConfDataMap(app *core.App, c *fiber.Ctx) ConfData

type JSONResult

type JSONResult struct {
	Msg  string      `json:"msg,omitempty"`  // Message
	Data interface{} `json:"data,omitempty"` // Data
}

JSONResult JSON Response data structure

type Map

type Map = map[string]interface{}

Jump to

Keyboard shortcuts

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