diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-06-14 11:58:28 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-06-14 11:58:28 -0600 |
commit | 5137859e47678aae81e178ca7d164f9e2b4e3121 (patch) | |
tree | f0e5cb9b9a4ad5dc03b53127fcea2a536bd6ee27 /modules/caddyhttp/responsewriter.go | |
parent | b8e7453fef3dac6036403bc384eec96becff5114 (diff) |
Rename caddy2 -> caddy
Removes the version from the package name
Diffstat (limited to 'modules/caddyhttp/responsewriter.go')
-rw-r--r-- | modules/caddyhttp/responsewriter.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/modules/caddyhttp/responsewriter.go b/modules/caddyhttp/responsewriter.go index 4599fd2..3bf3965 100644 --- a/modules/caddyhttp/responsewriter.go +++ b/modules/caddyhttp/responsewriter.go @@ -19,31 +19,31 @@ type ResponseWriterWrapper struct { } // Hijack implements http.Hijacker. It simply calls the underlying -// ResponseWriter's Hijack method if there is one, or returns an error. +// ResponseWriter's Hijack method if there is one, or returns +// ErrNotImplemented otherwise. func (rww *ResponseWriterWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) { if hj, ok := rww.ResponseWriter.(http.Hijacker); ok { return hj.Hijack() } - return nil, nil, fmt.Errorf("not a hijacker") + return nil, nil, ErrNotImplemented } // Flush implements http.Flusher. It simply calls the underlying -// ResponseWriter's Flush method if there is one, or panics. +// ResponseWriter's Flush method if there is one. func (rww *ResponseWriterWrapper) Flush() { if f, ok := rww.ResponseWriter.(http.Flusher); ok { f.Flush() - } else { - panic("not a flusher") } } // Push implements http.Pusher. It simply calls the underlying -// ResponseWriter's Push method if there is one, or returns an error. +// ResponseWriter's Push method if there is one, or returns +// ErrNotImplemented otherwise. func (rww *ResponseWriterWrapper) Push(target string, opts *http.PushOptions) error { - if pusher, hasPusher := rww.ResponseWriter.(http.Pusher); hasPusher { + if pusher, ok := rww.ResponseWriter.(http.Pusher); ok { return pusher.Push(target, opts) } - return fmt.Errorf("not a pusher") + return ErrNotImplemented } // HTTPInterfaces mix all the interfaces that middleware ResponseWriters need to support. @@ -54,5 +54,9 @@ type HTTPInterfaces interface { http.Hijacker } +// ErrNotImplemented is returned when an underlying +// ResponseWriter does not implement the required method. +var ErrNotImplemented = fmt.Errorf("method not implemented") + // Interface guards var _ HTTPInterfaces = (*ResponseWriterWrapper)(nil) |