httpx

package
v1.3.32 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func GetTokenDataFromCtx

func GetTokenDataFromCtx(ctx context.Context) (*jwtx.JwtTokenData, error)

从ctx获取用户请求内容

func GetTokenFromRequest

func GetTokenFromRequest(r *http.Request) (string, error)

读取Request Header Authorization

func IsAuthorize added in v1.3.29

func IsAuthorize(next http.HandlerFunc, canAccess func(r *http.Request) (*CanAccess, error)) http.HandlerFunc

func WithRawTokenDataContext added in v1.3.32

func WithRawTokenDataContext(ctx context.Context, r *http.Request, data jwtx.JwtTokenData) (*http.Request, error)

func WithRpcTokenContext added in v1.3.32

func WithRpcTokenContext(ctx context.Context, r *http.Request) (*http.Request, error)

透传给Rpc authorization 认证token

func WithTokenContext

func WithTokenContext(ctx context.Context, r *http.Request, secret string) (*http.Request, string, error)

设置请求token的上下文

Types

type CanAccess added in v1.3.29

type CanAccess struct {
	Access                bool
	TokenExpiredAt        int64
	RefreshTokenExpiredAt int64
	AccessToken           string
	TenantId              int64
	UserId                int64
	UserCode              string
	JwtToken              string
}

type TokenKey added in v1.3.32

type TokenKey string

func NewTokenKey added in v1.3.32

func NewTokenKey() TokenKey

type UserContextKey

type UserContextKey string

Jump to

Keyboard shortcuts

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