ctl

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSid

func GenerateSid(id *int64, key string) string

func GenerateToken

func GenerateToken(id int64, expire int, signKey []byte) (string, error)

Types

type AnyParam

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

func (*AnyParam) MustFloat64 added in v1.0.20

func (a *AnyParam) MustFloat64() (float64, error)

func (*AnyParam) MustInt64 added in v1.0.20

func (a *AnyParam) MustInt64() (int64, error)

func (*AnyParam) ToFloat64

func (a *AnyParam) ToFloat64() float64

func (*AnyParam) ToInt64

func (a *AnyParam) ToInt64() int64

type AuthController added in v1.0.24

type AuthController struct {
	Ctx
	CheckAuth func(ctx *fasthttp.RequestCtx) bool
	BeforeReq func(ctx *fasthttp.RequestCtx) bool
	// contains filtered or unexported fields
}

func (*AuthController) Auth added in v1.0.24

func (m *AuthController) Auth(ctx *fasthttp.RequestCtx, name, action string) bool

Auth 所有控制层的鉴权方法 返回 true 表示成功

func (*AuthController) SetSkipRule added in v1.0.24

func (m *AuthController) SetSkipRule(r *[][]string)

type Claims

type Claims struct {
	ID       int64
	Username string `json:"username"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token *string, signKey []byte) (*Claims, error)

type Ctx

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

func (*Ctx) AnyMultiParam added in v1.0.22

func (m *Ctx) AnyMultiParam(p string) (ap *AnyParam)

AnyMultiParam get arg with content-type: multipart/form-data

func (*Ctx) AnyPostParam added in v1.0.21

func (m *Ctx) AnyPostParam(p string) (ap *AnyParam)

AnyPostParam get arg with content-type: application/x-www-form-urlencoded

func (*Ctx) AnyUriParam added in v1.0.21

func (m *Ctx) AnyUriParam(p string) (ap *AnyParam)

AnyUriParam get an arg from query uri

func (*Ctx) Error

func (m *Ctx) Error(err string) error

func (*Ctx) File

func (m *Ctx) File(p string) *multipart.FileHeader

func (*Ctx) Header

func (m *Ctx) Header(p string) string

func (*Ctx) Html added in v1.0.22

func (m *Ctx) Html(str string) error

func (*Ctx) MultiParam added in v1.0.22

func (m *Ctx) MultiParam(p string) string

MultiParam get arg with content-type: multipart/form-data

func (*Ctx) PostParam added in v1.0.21

func (m *Ctx) PostParam(p string) string

PostParam get arg with content-type: application/x-www-form-urlencoded

func (*Ctx) Redirect

func (m *Ctx) Redirect(uri string)

func (*Ctx) RenderJson

func (m *Ctx) RenderJson(data any) *Msg

func (*Ctx) SetHeader

func (m *Ctx) SetHeader(k, v string)

func (*Ctx) SetStatusCode

func (m *Ctx) SetStatusCode(c int)

func (*Ctx) Success

func (m *Ctx) Success(msg string) error

func (*Ctx) Text added in v1.0.22

func (m *Ctx) Text(str string) error

func (*Ctx) UriParam added in v1.0.21

func (m *Ctx) UriParam(p string) string

UriParam get an arg from query uri

func (*Ctx) WithCtx

func (m *Ctx) WithCtx(ctx *fasthttp.RequestCtx) *Ctx

type EmptyController added in v1.0.20

type EmptyController struct {
	Ctx
}

EmptyController do nothing

type IMember

type IMember interface {
	CheckSid(id *int64, sid *string) bool
}

type JwtController

type JwtController struct {
	Ctx

	AuthOk func(id *int64) bool
	// contains filtered or unexported fields
}

func (*JwtController) Auth

func (m *JwtController) Auth(ctx *fasthttp.RequestCtx, name, action string) bool

Auth 所有控制层的鉴权方法 返回 true 表示成功

func (*JwtController) InitJwt

func (m *JwtController) InitJwt(signKey []byte)

func (*JwtController) SetSkipRule

func (m *JwtController) SetSkipRule(r *[][]string)

type Msg

type Msg struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
	// contains filtered or unexported fields
}

func (*Msg) Err

func (msg *Msg) Err(str string) *Msg

func (*Msg) Ok

func (msg *Msg) Ok(str string) *Msg

func (*Msg) Out

func (msg *Msg) Out() error

type SidController

type SidController struct {
	AuthController
	CheckAuth func(sid *string, ctx *fasthttp.RequestCtx) bool
}

func (*SidController) Auth

func (m *SidController) Auth(ctx *fasthttp.RequestCtx, name, action string) bool

Auth 所有控制层的鉴权方法 返回 true 表示成功

Jump to

Keyboard shortcuts

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