Documentation ¶
Index ¶
- Variables
- func Auth(ctx *fasthttp.RequestCtx) (success bool, authorizeURI string)
- func GetAccessToken(ctx *fasthttp.RequestCtx) (accessToken string, ok bool)
- func GetTokenValue(token, key string) (value interface{})
- func InitAuth(config *Config)
- func IsAjaxRequest(ctx *fasthttp.RequestCtx) bool
- func ResponseJSON(ctx *fasthttp.RequestCtx, response interface{})
- func SetCookie(key, value string, expire int, ctx *fasthttp.RequestCtx)
- func TodayRemainSecond() int
- type Config
Constants ¶
This section is empty.
Variables ¶
var DebugConf = &Config{ EnableAuth: true, EnableDebug: false, DebugUser: "", AuthUrl: "https://xtbgtest.digitalgd.com.cn/pps/auth", ClientId: "workbench", Secret: "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALIJSI7be4tZFmC2AtQTcXZuCVg1k+gLuoE/rDcR9E5nWDw21669/pqVgb2ay6VBL4dGVXL/TFQnpQT6s3WhlBUCAwEAAQ==", CallbackURI: "http://10.101.101.7:8080/demo/callback?call_uri=", DefaultRedirectUrl: "http://10.101.101.7:8080/demo/index", }
Functions ¶
func Auth ¶
func Auth(ctx *fasthttp.RequestCtx) (success bool, authorizeURI string)
Auth 请求接口认证包装方法,success:认证是否通过,authorizeURI:认证不通过时,返回重定向粤政易认证地址链接
func GetAccessToken ¶
func GetAccessToken(ctx *fasthttp.RequestCtx) (accessToken string, ok bool)
GetAccessToken 从cookie或header取access_token
func GetTokenValue ¶
func GetTokenValue(token, key string) (value interface{})
GetTokenValue 根据key获取token中的value access token demo: eyJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJ3b3JrYmVuY2giLCJzdWIiOiJ4ejJvYzQ1N2syMTVqMHFqZ3BvMGw2Iiwicm9sZXMiOiJ7fSIsImlzcyI6ImRpZ2l0YWxnZCIsImV4cCI6MTY0NDgxNjgyMCwibm9uY2UiOiJjOGMyOWI0ZDliY2JhMTQxNmZjYmIwNGQzNjY3OTdiZCMyIiwiaWF0IjoxNjQ0ODA5NjIwfQ.gYbomslVH4x0Y8Tvnd64jDJNnMmg5XtpO7S4NxRZm9uUWOXG5yQVfu4mG5wCBFVrS7Li-qTrd9IPqIQrZ1tiXw payload:{"aud":"workbench","sub":"xz2oc457k215j0qjgpo0l6","roles":"{}","iss":"digitalgd","exp":1644816820,"nonce":"c8c29b4d9bcba1416fcbb04d366797bd#2","iat":1644809620}
func IsAjaxRequest ¶
func IsAjaxRequest(ctx *fasthttp.RequestCtx) bool
func ResponseJSON ¶
func ResponseJSON(ctx *fasthttp.RequestCtx, response interface{})
ResponseJSON fasthttp响应JSON格式结果