2 Star 0 Fork 0

TeamsHub/backend-gopkg

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
headers.go 843 Bytes
Copy Edit Raw Blame History
HCY authored 2024-05-10 12:41 +08:00 . c
// Copyright 2019 chnykn@gmail.com All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package toolfunc
import (
"encoding/base64"
"github.com/imroc/req"
)
//Headers ***
type Headers struct {
Header req.Header // = make(Header)
}
//NewHeaders ***
func NewHeaders() *Headers {
o := &Headers{
Header: make(req.Header),
}
o.Header["Content-Type"] = "application/json"
return o
}
//AddBasicAuthHeader ***
func (o *Headers) AddBasicAuthHeader(appKey string, appSecret string) {
key := appKey + ":" + appSecret
authorization := "Basic" + " " + base64.StdEncoding.EncodeToString([]byte(key))
o.Header["Authorization"] = authorization
}
//AddOAuth2Header ***
func (o *Headers) AddOAuth2Header(token string) {
o.Header["Authorization"] = "Bearer " + token
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzheng0709/backend-gopkg.git
git@gitee.com:wuzheng0709/backend-gopkg.git
wuzheng0709
backend-gopkg
backend-gopkg
v1.4.4

Search