httpx

package
v1.3.29 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 9 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() (CanAccess, error)) http.HandlerFunc

func WithTokenContext

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

设置请求token的上下文

func WithTokenDataContext added in v1.3.24

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

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 UserContextKey

type UserContextKey string

Jump to

Keyboard shortcuts

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