1 Star 0 Fork 0

yangx282441848/scm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
scm
driver
transport
internal
oauth1
oauth2
auth.go
auth_test.go
basicauth.go
basicauth_test.go
bearer.go
bearer_test.go
custom.go
custom_test.go
doc.go
private.go
private_test.go
util.go
util_test.go
client.go
client_test.go
const.go
content.go
example_test.go
git.go
issue.go
linker.go
milestone.go
org.go
pr.go
release.go
repo.go
review.go
token.go
user.go
util.go
util_test.go
webhook.go
vendor
.drone.yml
.github_changelog_generator
.gitignore
BUILDING
CHANGELOG.md
COPYRIGHT
HISTORY.md
LICENSE
README.md
go.mod
go.sum
克隆/下载
custom.go 922 Bytes
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2018 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package transport
import "net/http"
// Custom is an http.RoundTripper that can be used to
// implement custom HTTP request authorization.
type Custom struct {
Base http.RoundTripper
// Before defines an func to mutate the http.Request
// before the transaction is executed.
Before func(*http.Request)
}
// RoundTrip authorizes and authenticates the request with
// a user-defined function.
func (t *Custom) RoundTrip(r *http.Request) (*http.Response, error) {
r2 := cloneRequest(r)
t.Before(r2)
return t.base().RoundTrip(r2)
}
// base returns the base transport. If no base transport
// is configured, the default transport is returned.
func (t *Custom) base() http.RoundTripper {
if t.Base != nil {
return t.Base
}
return http.DefaultTransport
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangx282441848/scm.git
git@gitee.com:yangx282441848/scm.git
yangx282441848
scm
scm
v1.16.14

搜索帮助