httpx

package
v1.3.75 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JwtTokenDataKey     = UserContextKey("JwtTokenData")
	AdminUserContextKey = UserContextKey("UserContext")
)
View Source
const (
	REFESH_TOKEN_EXPIRED_AT = "refresh-token-expired-at"
	TOKEN_EXPIRED_AT        = "access-token-expired-at"
)

Variables

This section is empty.

Functions

func AdminHandle added in v1.3.40

func AdminHandle(next http.HandlerFunc) http.HandlerFunc

透传给Rpc authorization 认证token

func CanAccess added in v1.3.29

func CanAccess(next http.HandlerFunc, check func(r *http.Request) (*CanAccessResp, error)) http.HandlerFunc

检查是否可以访问资源

func GetJwtTokenDataFromCtx added in v1.3.35

func GetJwtTokenDataFromCtx(ctx context.Context) (*jwtx.JwtTokenData, *errx.Error)

从ctx获取用户请求内容

func GetTokenFromRequest

func GetTokenFromRequest(r *http.Request) (string, *errx.Error)

读取Request Header Authorization

func GetUserContextFromCtx added in v1.3.39

func GetUserContextFromCtx(ctx context.Context) (*sessionx.UserContext, *errx.Error)

获取后台用户上下文

func WithJwtTokenContext added in v1.3.35

func WithJwtTokenContext(ctx context.Context, r *http.Request, secret string) (*http.Request, string, *errx.Error)

设置请求token的上下文

func WithTokenDataContext added in v1.3.24

func WithTokenDataContext(ctx context.Context, r *http.Request, data jwtx.JwtTokenData) (*http.Request, *errx.Error)

设置JwtTokenData

Types

type CanAccessResp added in v1.3.41

type CanAccessResp struct {
	Access                bool
	TokenExpiredAt        int64
	RefreshTokenExpiredAt int64
	AccessToken           string
	TenantId              int64
	TenantCode            string
	UserId                int64
	UserCode              string
	UserName              string
	Mobile                string
	Mail                  string
	JwtToken              string
	PermissionGroup       string // 权限组
	PermissionCode        string // 权限码
	TraceId               string
	SpanId                string
}

type RpcTokenKey added in v1.3.37

type RpcTokenKey string

func NewRpcTokenKey added in v1.3.37

func NewRpcTokenKey() RpcTokenKey

type UserContextKey

type UserContextKey string

Jump to

Keyboard shortcuts

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