HTTP server NoOpRequestDecoder#659
Conversation
transport/http/server.go
Outdated
|
|
||
| // NoOpRequestDecoder is a DecodeRequestFunc that can be used for requests that do not | ||
| // need to be decoded, and simply returns nil, nil. | ||
| func NoOpRequestDecoder(ctx context.Context, r *http.Request) (interface{}, error) { |
There was a problem hiding this comment.
I know it might look a bit strange, but I think in Go we usually spell this NopRequestDecoder. See for precedent:
https://golang.org/pkg/io/ioutil/#NopCloser
https://godoc.org/github.com/go-kit/kit/log#NewNopLogger
https://godoc.org/golang.org/x/text/transform#NopResetter
| case <-done: | ||
| case <-time.After(time.Second): | ||
| t.Fatal("timeout waiting for finalizer") | ||
| } |
There was a problem hiding this comment.
I think this test is doing too much. It seems to me that it would be perfectly valid to test this without spinning up an http server and extra goroutines. Consider calling handler.ServeHTTP directly. You can use httptest.NewRequest and httptest.NewRecorder to construct appropriate arguments for ServeHTTP and do it all sequentially with no need for worrying about timeouts, done channels or stopping a server.
Adds NoOpRequestDecoder for HTTP request that do not need to be decoded. Fixes go-kit#657
|
@ChrisHines Thanks for the review. I made the requested changes. Cheers. |
|
Fun! Thanks! I guess we ought to do a release soon... |
Adds NoOpRequestDecoder for HTTP request that do not need to be decoded.
Fixes #657