diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-10 21:07:02 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-10 21:07:02 -0600 |
commit | 8ae0d6a509fd1b871457cf742369af04346933a8 (patch) | |
tree | 9a0b977e5f36acc6f06737ff34b1f21d608ada6f /modules/caddyhttp/responsewriter.go | |
parent | 48b5a803208548d143b7ead9b6fc9b524cd0e031 (diff) |
caddyhttp: Implement better HTTP matchers including regexp; add tests
Diffstat (limited to 'modules/caddyhttp/responsewriter.go')
-rw-r--r-- | modules/caddyhttp/responsewriter.go | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/modules/caddyhttp/responsewriter.go b/modules/caddyhttp/responsewriter.go index 8aefd3f..4599fd2 100644 --- a/modules/caddyhttp/responsewriter.go +++ b/modules/caddyhttp/responsewriter.go @@ -7,16 +7,13 @@ import ( "net/http" ) -// TODO: Is this type really required? Wouldn't embedding the -// default ResponseWriter always work too, when wrapping it? - // ResponseWriterWrapper wraps an underlying ResponseWriter and -// promotes its Pusher/Flusher/CloseNotifier/Hijacker methods -// as well. To use this type, embed a pointer to it within your -// own struct type that implements the http.ResponseWriter -// interface, then call methods on the embedded value. You can -// make sure your type wraps correctly by asserting that it -// implements the HTTPInterfaces interface. +// promotes its Pusher/Flusher/Hijacker methods as well. To use +// this type, embed a pointer to it within your own struct type +// that implements the http.ResponseWriter interface, then call +// methods on the embedded value. You can make sure your type +// wraps correctly by asserting that it implements the +// HTTPInterfaces interface. type ResponseWriterWrapper struct { http.ResponseWriter } @@ -40,15 +37,6 @@ func (rww *ResponseWriterWrapper) Flush() { } } -// CloseNotify implements http.CloseNotifier. It simply calls the underlying -// ResponseWriter's CloseNotify method if there is one, or panics. -func (rww *ResponseWriterWrapper) CloseNotify() <-chan bool { - if cn, ok := rww.ResponseWriter.(http.CloseNotifier); ok { - return cn.CloseNotify() - } - panic("not a close notifier") -} - // Push implements http.Pusher. It simply calls the underlying // ResponseWriter's Push method if there is one, or returns an error. func (rww *ResponseWriterWrapper) Push(target string, opts *http.PushOptions) error { @@ -63,7 +51,6 @@ type HTTPInterfaces interface { http.ResponseWriter http.Pusher http.Flusher - http.CloseNotifier http.Hijacker } |