Fix lint and format code in client/httplib dir
This commit is contained in:
parent
ca328208cc
commit
c28ae80b11
@ -8,6 +8,7 @@
|
||||
- Lint: use golangci-lint. [4619](https://github.com/beego/beego/pull/4619)
|
||||
- Fix lint and format code in adapter/httplib dir [4648](https://github.com/beego/beego/pull/4648)
|
||||
- Chore: format code. [4615](https://github.com/beego/beego/pull/4615)
|
||||
- Fix lint and format code in client/httplib dir [4652](https://github.com/beego/beego/pull/4652)
|
||||
- Test on Go v1.15.x & v1.16.x. [4614](https://github.com/beego/beego/pull/4614)
|
||||
- Env: non-empty GOBIN & GOPATH. [4613](https://github.com/beego/beego/pull/4613)
|
||||
- Chore: update dependencies. [4611](https://github.com/beego/beego/pull/4611)
|
||||
|
||||
@ -35,9 +35,7 @@ type FilterChainBuilder struct {
|
||||
}
|
||||
|
||||
func (builder *FilterChainBuilder) FilterChain(next httplib.Filter) httplib.Filter {
|
||||
|
||||
return func(ctx context.Context, req *httplib.BeegoHTTPRequest) (*http.Response, error) {
|
||||
|
||||
method := req.GetRequest().Method
|
||||
|
||||
operationName := method + "#" + req.GetRequest().URL.String()
|
||||
|
||||
@ -32,11 +32,12 @@ type FilterChainBuilder struct {
|
||||
RunMode string
|
||||
}
|
||||
|
||||
var summaryVec prometheus.ObserverVec
|
||||
var initSummaryVec sync.Once
|
||||
var (
|
||||
summaryVec prometheus.ObserverVec
|
||||
initSummaryVec sync.Once
|
||||
)
|
||||
|
||||
func (builder *FilterChainBuilder) FilterChain(next httplib.Filter) httplib.Filter {
|
||||
|
||||
initSummaryVec.Do(func() {
|
||||
summaryVec = prometheus.NewSummaryVec(prometheus.SummaryOpts{
|
||||
Name: "beego",
|
||||
|
||||
@ -400,7 +400,6 @@ func (b *BeegoHTTPRequest) handleFileToBody(bodyWriter *multipart.Writer, formna
|
||||
"could not create form file, formname: %s, filename: %s", formname, filename))
|
||||
}
|
||||
fh, err := os.Open(filename)
|
||||
|
||||
if err != nil {
|
||||
logs.Error(errFmt, berror.Wrapf(err, ReadFileFailed, "could not open this file %s", filename))
|
||||
}
|
||||
|
||||
@ -63,7 +63,6 @@ func TestDoRequest(t *testing.T) {
|
||||
if elapsedTime < delayedTime {
|
||||
t.Errorf("Not enough retries. Took %dms. Delay was meant to take %dms", elapsedTime, delayedTime)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
@ -248,7 +247,6 @@ func TestToJson(t *testing.T) {
|
||||
t.Fatal("response is not valid ip")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestToFile(t *testing.T) {
|
||||
|
||||
@ -23,10 +23,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
func TestSimpleCondition_MatchPath(t *testing.T) {
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
res := sc.Match(context.Background(), httplib.Get("http://localhost:8080/abc/s"))
|
||||
@ -72,7 +68,6 @@ func TestSimpleCondition_MatchHeader(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSimpleCondition_MatchBodyField(t *testing.T) {
|
||||
|
||||
sc := NewSimpleCondition("/abc/s")
|
||||
req := httplib.Post("http://localhost:8080/abc/s")
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ import (
|
||||
)
|
||||
|
||||
func TestStartMock(t *testing.T) {
|
||||
|
||||
// httplib.defaultSetting.FilterChains = []httplib.FilterChain{mockFilter.FilterChain}
|
||||
|
||||
stub := StartMock()
|
||||
@ -41,7 +40,6 @@ func TestStartMock(t *testing.T) {
|
||||
|
||||
assert.Equal(t, expectedErr, err)
|
||||
assert.Equal(t, expectedResp, resp)
|
||||
|
||||
}
|
||||
|
||||
// TestStartMock_Isolation Test StartMock that
|
||||
|
||||
@ -68,8 +68,10 @@ var defaultSetting = BeegoHTTPSettings{
|
||||
FilterChains: make([]FilterChain, 0, 4),
|
||||
}
|
||||
|
||||
var defaultCookieJar http.CookieJar
|
||||
var settingMutex sync.Mutex
|
||||
var (
|
||||
defaultCookieJar http.CookieJar
|
||||
settingMutex sync.Mutex
|
||||
)
|
||||
|
||||
// AddDefaultFilter add a new filter into defaultSetting
|
||||
// Be careful about using this method if you invoke SetDefaultSetting somewhere
|
||||
|
||||
@ -18,8 +18,10 @@ import (
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
)
|
||||
|
||||
var port = ""
|
||||
var baseURL = "http://localhost:"
|
||||
var (
|
||||
port = ""
|
||||
baseURL = "http://localhost:"
|
||||
)
|
||||
|
||||
// TestHTTPRequest beego test request client
|
||||
type TestHTTPRequest struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user