xhttp

package module
v0.0.0-...-eb0ad2e Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: GPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

xhttp

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyToken   = errors.New("not found token in header")
	ErrTokenInvalid = errors.New("token is invalid")
)

Functions

func BadRequestResponse

func BadRequestResponse(ctx *gin.Context, err error)

func ForbiddenResponse

func ForbiddenResponse(ctx *gin.Context, err error)

func GatewayTimeoutResponse

func GatewayTimeoutResponse(ctx *gin.Context, err error)

func InternalServerErrorResponse

func InternalServerErrorResponse(ctx *gin.Context, err error)

func NotFoundResponse

func NotFoundResponse(ctx *gin.Context, err error)

func NotImplementedResponse

func NotImplementedResponse(ctx *gin.Context, err error)

func ServiceUnavailableResponse

func ServiceUnavailableResponse(ctx *gin.Context, err error)

func SuccessResponse

func SuccessResponse(ctx *gin.Context, data interface{})

func UnauthorizedResponse

func UnauthorizedResponse(ctx *gin.Context, err error)

Types

type Authorization

type Authorization interface {
	Verify(claims jwt.Claims) bool
	GetEmptyMyClaims() jwt.Claims
}

type JwtOptions

type JwtOptions struct {
	Secret string
	Lookup string
	Auth   Authorization
}

type Response

type Response struct {
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type XHttp

type XHttp struct {
	Engine *gin.Engine
	// contains filtered or unexported fields
}

func NewXHttp

func NewXHttp() *XHttp

func (*XHttp) AddOnStartFunc

func (h *XHttp) AddOnStartFunc(fn []func())

func (*XHttp) AddOnStopFunc

func (h *XHttp) AddOnStopFunc(fn []func())

func (*XHttp) RegisterGlobalMiddleware

func (h *XHttp) RegisterGlobalMiddleware(middles []func(c *gin.Context))

func (*XHttp) Start

func (h *XHttp) Start()

type XJwt

type XJwt struct {
	Secret    []byte
	LookupKey string
	Auth      Authorization
}

func NewXJwt

func NewXJwt(options JwtOptions) *XJwt

func (*XJwt) GenerateToken

func (j *XJwt) GenerateToken(claims jwt.Claims) (sign string, err error)

func (*XJwt) Middleware

func (j *XJwt) Middleware(exception map[string]byte) gin.HandlerFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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