giris

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTokenExpired     = "令牌已过期"
	ErrorTokenNotValidYet = "令牌不存在"
	ErrorTokenMalformed   = "错误的令牌"
	ErrorTokenInvalid     = "令牌已失效"
	ErrorTokenMissing     = "非法访问"
)
View Source
const (
	JWTToken    = "JWT_TOKEN"
	ContextUser = "CONTEXT_USER"
)

Variables

View Source
var App = new(AppStart)
View Source
var IncJWT = new(JWT)

Functions

func Addr

func Addr(addr string, hostConfigs ...host.Configurator) iris.Runner

func AddrServer

func AddrServer(addr string) *http.Server

func AllocsHandler

func AllocsHandler() iris.Handler

AllocsHandler will pass the call from /debug/pprof/allocs to pprof

func BindRestAPIs

func BindRestAPIs(g iris.Party, api interface{})

func BlockHandler

func BlockHandler() iris.Handler

BlockHandler will pass the call from /debug/pprof/block to pprof

func CmdlineHandler

func CmdlineHandler() iris.Handler

CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof

func ConcurrentLimit

func ConcurrentLimit(n int) iris.Handler

func Func2Handler

func Func2Handler(fn interface{}) iris.Handler

func GoroutineHandler

func GoroutineHandler() iris.Handler

GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof

func HeapHandler

func HeapHandler() iris.Handler

HeapHandler will pass the call from /debug/pprof/heap to pprof

func HttpHandler2IrisHandler

func HttpHandler2IrisHandler(h http.Handler) iris.Handler

func IndexHandler

func IndexHandler() iris.Handler

IndexHandler will pass the call from /debug/pprof to pprof

func JSON

func JSON(c iris.Context, code int, val ...interface{})

JSON ...

func MutexHandler

func MutexHandler() iris.Handler

MutexHandler will pass the call from /debug/pprof/mutex to pprof

func PProfWrapGroup

func PProfWrapGroup(party iris.Party)

PProfWrapGroup adds several routes from package `net/http/pprof` to *gin.RouterGroup object

func ProfileHandler

func ProfileHandler() iris.Handler

ProfileHandler will pass the call from /debug/pprof/profile to pprof

func QueueClearExpiredPattern

func QueueClearExpiredPattern() string

func RPCServer2IrisHandler

func RPCServer2IrisHandler(h j2rpc.RPCServer) iris.Handler

func RateLimiter

func RateLimiter() context.Handler

func SetCrypto

func SetCrypto(k string)

SetCrypto ... must replace with your own crypto

func SymbolHandler

func SymbolHandler() iris.Handler

SymbolHandler will pass the call from /debug/pprof/symbol to pprof

func ThreadCreateHandler

func ThreadCreateHandler() iris.Handler

ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof

func TraceHandler

func TraceHandler() iris.Handler

TraceHandler will pass the call from /debug/pprof/trace to pprof

Types

type AppStart

type AppStart struct {
	IrisApp   *iris.Application `inject:""`
	Config    *config.Config    `inject:""`
	WebLogger *midLogger        `inject:""`
	Captcha   *Captcha          `inject:""`
	JWT       *JWT              `inject:""`
	Validator *util.Validator   `inject:""`
	RPC       j2rpc.RPCServer   `inject:""`
	SysLogger util.ItfLogger    `inject:""`

	RPCServerFunc func(server j2rpc.RPCServer)
	// contains filtered or unexported fields
}

func (*AppStart) Constructor

func (a *AppStart) Constructor()

func (*AppStart) RootParty

func (a *AppStart) RootParty() iris.Party

func (*AppStart) RouteApp

func (a *AppStart) RouteApp() iris.Party

RouteApp ......

func (*AppStart) Shutdown

func (a *AppStart) Shutdown()

Shutdown ...

func (*AppStart) StartApp

func (a *AppStart) StartApp()

StartApp ......

func (*AppStart) Wait

func (a *AppStart) Wait()

Wait ...

type Captcha

type Captcha struct {
	Driver base64Captcha.Driver
	Store  base64Captcha.Store
	// contains filtered or unexported fields
}

func (*Captcha) Captcha

func (c *Captcha) Captcha() iris.Handler

Captcha ......

func (*Captcha) Generate

func (c *Captcha) Generate() (arg CaptchaArg, err error)

func (*Captcha) Verify

func (c *Captcha) Verify(arg *CaptchaArg) bool

type CaptchaArg

type CaptchaArg struct {
	ID      string `json:"id"`
	Answer  string `json:"answer,omitempty"`
	Content string `json:"content,omitempty"`
}

type JSONResponse

type JSONResponse struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

JSONResponse ...

type JWT

type JWT struct {
	// jwt settings
	Expire int64
	// contains filtered or unexported fields
}

JWT is a middleware for the RPC web framework that provides JWT authentication.

func (*JWT) AfterLogin

func (j *JWT) AfterLogin(id string) (t *Token, err error)

AfterLogin ...

func (*JWT) ClearExpiredFunc

func (j *JWT) ClearExpiredFunc() func()

ClearExpiredFunc Clear expired tokens

func (*JWT) Logout

func (j *JWT) Logout(id string)

Logout ...

func (*JWT) User

func (*JWT) User(ctx iris.Context) interface{}

func (*JWT) Verify

func (j *JWT) Verify(c iris.Context, call func(id string) (user interface{}, err error)) (err error)

Verify verifies the token and returns the user ID if the token is valid.

type Token

type Token struct {
	ID        string `json:"id,omitempty"`
	ExpiresAt int64  `json:"expires_at,omitempty"`
	Token     string `json:"token,omitempty"`
}

func (*Token) Expired

func (t *Token) Expired() bool

Jump to

Keyboard shortcuts

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