Skip to content

Commit 193d1e1

Browse files
committed
Update xhttp middleware
1 parent 51d38e3 commit 193d1e1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ go get github.com/mix-go/xhttp
2222
| xhttp.WithTimeout(timeout time.Duration) RequestOption | Set configuration item. |
2323
| xhttp.WithDebugFunc(f DebugFunc) RequestOption | Set configuration item. |
2424
| xhttp.WithRetry(f RetryIfFunc, opts ...retry.Option) RequestOption | Set configuration item. |
25-
| xhttp.WithMiddlewares(middlewares ...Middleware) RequestOption | Set configuration item. |
25+
| xhttp.WithMiddleware(middlewares ...Middleware) RequestOption | Set configuration item. |
2626
| xhttp.BuildJSON(v interface{}) Body | Generate json string. |
2727
| xhttp.BuildQuery(m map[string]string) Body | Generate urlencoded query string. |
2828
| xhttp.Shutdown(ctx context.Context) | Do shutdown. |
@@ -112,7 +112,7 @@ logicMiddleware := func(next xhttp.HandlerFunc) xhttp.HandlerFunc {
112112
return resp, err
113113
}
114114
}
115-
resp, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddlewares(logicMiddleware))
115+
resp, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddleware(logicMiddleware))
116116
```
117117

118118
## Shutdown

client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func TestMiddlewares(t *testing.T) {
138138
return resp, err
139139
}
140140
}
141-
resp, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddlewares(logicMiddleware))
141+
resp, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddleware(logicMiddleware))
142142

143143
a.Equal(resp.StatusCode, 200)
144144
a.Nil(err)
@@ -160,14 +160,14 @@ func TestShutdown(t *testing.T) {
160160
return resp, err
161161
}
162162
}
163-
_, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddlewares(logicMiddleware))
163+
_, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddleware(logicMiddleware))
164164
a.Nil(err)
165165
wg := sync.WaitGroup{}
166166
wg.Add(3)
167167
for i := 0; i < 3; i++ {
168168
go func(i int, wg *sync.WaitGroup) {
169169
defer wg.Done()
170-
_, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddlewares(logicMiddleware))
170+
_, err := xhttp.NewRequest("GET", "https://github.com/", xhttp.WithMiddleware(logicMiddleware))
171171
a.Equal(err, xhttp.ErrShutdown)
172172
}(i, &wg)
173173
}

options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func WithRetry(f RetryIfFunc, opts ...retry.Option) RequestOption {
102102
}}
103103
}
104104

105-
func WithMiddlewares(middlewares ...Middleware) RequestOption {
105+
func WithMiddleware(middlewares ...Middleware) RequestOption {
106106
return &funcRequestOption{func(o *RequestOptions) {
107107
o.Middlewares = append(o.Middlewares, middlewares...)
108108
}}

0 commit comments

Comments
 (0)