Merge pull request #427 from edaniels/patch-1
Make delegators wrapping responseWriterDelegator have value receivers
This commit is contained in:
commit
472be16acf
|
@ -76,16 +76,16 @@ type flusherDelegator struct{ *responseWriterDelegator }
|
||||||
type hijackerDelegator struct{ *responseWriterDelegator }
|
type hijackerDelegator struct{ *responseWriterDelegator }
|
||||||
type readerFromDelegator struct{ *responseWriterDelegator }
|
type readerFromDelegator struct{ *responseWriterDelegator }
|
||||||
|
|
||||||
func (d *closeNotifierDelegator) CloseNotify() <-chan bool {
|
func (d closeNotifierDelegator) CloseNotify() <-chan bool {
|
||||||
return d.ResponseWriter.(http.CloseNotifier).CloseNotify()
|
return d.ResponseWriter.(http.CloseNotifier).CloseNotify()
|
||||||
}
|
}
|
||||||
func (d *flusherDelegator) Flush() {
|
func (d flusherDelegator) Flush() {
|
||||||
d.ResponseWriter.(http.Flusher).Flush()
|
d.ResponseWriter.(http.Flusher).Flush()
|
||||||
}
|
}
|
||||||
func (d *hijackerDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
func (d hijackerDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||||
return d.ResponseWriter.(http.Hijacker).Hijack()
|
return d.ResponseWriter.(http.Hijacker).Hijack()
|
||||||
}
|
}
|
||||||
func (d *readerFromDelegator) ReadFrom(re io.Reader) (int64, error) {
|
func (d readerFromDelegator) ReadFrom(re io.Reader) (int64, error) {
|
||||||
if !d.wroteHeader {
|
if !d.wroteHeader {
|
||||||
d.WriteHeader(http.StatusOK)
|
d.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
@ -102,34 +102,34 @@ func init() {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
pickDelegator[closeNotifier] = func(d *responseWriterDelegator) delegator { // 1
|
pickDelegator[closeNotifier] = func(d *responseWriterDelegator) delegator { // 1
|
||||||
return &closeNotifierDelegator{d}
|
return closeNotifierDelegator{d}
|
||||||
}
|
}
|
||||||
pickDelegator[flusher] = func(d *responseWriterDelegator) delegator { // 2
|
pickDelegator[flusher] = func(d *responseWriterDelegator) delegator { // 2
|
||||||
return &flusherDelegator{d}
|
return flusherDelegator{d}
|
||||||
}
|
}
|
||||||
pickDelegator[flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 3
|
pickDelegator[flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 3
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[hijacker] = func(d *responseWriterDelegator) delegator { // 4
|
pickDelegator[hijacker] = func(d *responseWriterDelegator) delegator { // 4
|
||||||
return &hijackerDelegator{d}
|
return hijackerDelegator{d}
|
||||||
}
|
}
|
||||||
pickDelegator[hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 5
|
pickDelegator[hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 5
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &hijackerDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, hijackerDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 6
|
pickDelegator[hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 6
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &hijackerDelegator{d}, &flusherDelegator{d}}
|
}{d, hijackerDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 7
|
pickDelegator[hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 7
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -137,7 +137,7 @@ func init() {
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &hijackerDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, hijackerDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom] = func(d *responseWriterDelegator) delegator { // 8
|
pickDelegator[readerFrom] = func(d *responseWriterDelegator) delegator { // 8
|
||||||
return readerFromDelegator{d}
|
return readerFromDelegator{d}
|
||||||
|
@ -147,14 +147,14 @@ func init() {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &readerFromDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, readerFromDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom+flusher] = func(d *responseWriterDelegator) delegator { // 10
|
pickDelegator[readerFrom+flusher] = func(d *responseWriterDelegator) delegator { // 10
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &readerFromDelegator{d}, &flusherDelegator{d}}
|
}{d, readerFromDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 11
|
pickDelegator[readerFrom+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 11
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -162,14 +162,14 @@ func init() {
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &readerFromDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, readerFromDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom+hijacker] = func(d *responseWriterDelegator) delegator { // 12
|
pickDelegator[readerFrom+hijacker] = func(d *responseWriterDelegator) delegator { // 12
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
}{d, &readerFromDelegator{d}, &hijackerDelegator{d}}
|
}{d, readerFromDelegator{d}, hijackerDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom+hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 13
|
pickDelegator[readerFrom+hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 13
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -177,7 +177,7 @@ func init() {
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &readerFromDelegator{d}, &hijackerDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, readerFromDelegator{d}, hijackerDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom+hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 14
|
pickDelegator[readerFrom+hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 14
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -185,7 +185,7 @@ func init() {
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &readerFromDelegator{d}, &hijackerDelegator{d}, &flusherDelegator{d}}
|
}{d, readerFromDelegator{d}, hijackerDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[readerFrom+hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 15
|
pickDelegator[readerFrom+hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 15
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -194,6 +194,6 @@ func init() {
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &readerFromDelegator{d}, &hijackerDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, readerFromDelegator{d}, hijackerDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,27 +22,27 @@ import (
|
||||||
|
|
||||||
type pusherDelegator struct{ *responseWriterDelegator }
|
type pusherDelegator struct{ *responseWriterDelegator }
|
||||||
|
|
||||||
func (d *pusherDelegator) Push(target string, opts *http.PushOptions) error {
|
func (d pusherDelegator) Push(target string, opts *http.PushOptions) error {
|
||||||
return d.ResponseWriter.(http.Pusher).Push(target, opts)
|
return d.ResponseWriter.(http.Pusher).Push(target, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pickDelegator[pusher] = func(d *responseWriterDelegator) delegator { // 16
|
pickDelegator[pusher] = func(d *responseWriterDelegator) delegator { // 16
|
||||||
return &pusherDelegator{d}
|
return pusherDelegator{d}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 17
|
pickDelegator[pusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 17
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Pusher
|
http.Pusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+flusher] = func(d *responseWriterDelegator) delegator { // 18
|
pickDelegator[pusher+flusher] = func(d *responseWriterDelegator) delegator { // 18
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Pusher
|
http.Pusher
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &pusherDelegator{d}, &flusherDelegator{d}}
|
}{d, pusherDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 19
|
pickDelegator[pusher+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 19
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -50,14 +50,14 @@ func init() {
|
||||||
http.Pusher
|
http.Pusher
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+hijacker] = func(d *responseWriterDelegator) delegator { // 20
|
pickDelegator[pusher+hijacker] = func(d *responseWriterDelegator) delegator { // 20
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Pusher
|
http.Pusher
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
}{d, &pusherDelegator{d}, &hijackerDelegator{d}}
|
}{d, pusherDelegator{d}, hijackerDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 21
|
pickDelegator[pusher+hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 21
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -65,7 +65,7 @@ func init() {
|
||||||
http.Pusher
|
http.Pusher
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &hijackerDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, hijackerDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 22
|
pickDelegator[pusher+hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 22
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -73,7 +73,7 @@ func init() {
|
||||||
http.Pusher
|
http.Pusher
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &pusherDelegator{d}, &hijackerDelegator{d}, &flusherDelegator{d}}
|
}{d, pusherDelegator{d}, hijackerDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { //23
|
pickDelegator[pusher+hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { //23
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -82,14 +82,14 @@ func init() {
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &hijackerDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, hijackerDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom] = func(d *responseWriterDelegator) delegator { // 24
|
pickDelegator[pusher+readerFrom] = func(d *responseWriterDelegator) delegator { // 24
|
||||||
return struct {
|
return struct {
|
||||||
*responseWriterDelegator
|
*responseWriterDelegator
|
||||||
http.Pusher
|
http.Pusher
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+closeNotifier] = func(d *responseWriterDelegator) delegator { // 25
|
pickDelegator[pusher+readerFrom+closeNotifier] = func(d *responseWriterDelegator) delegator { // 25
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -97,7 +97,7 @@ func init() {
|
||||||
http.Pusher
|
http.Pusher
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+flusher] = func(d *responseWriterDelegator) delegator { // 26
|
pickDelegator[pusher+readerFrom+flusher] = func(d *responseWriterDelegator) delegator { // 26
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -105,7 +105,7 @@ func init() {
|
||||||
http.Pusher
|
http.Pusher
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &flusherDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 27
|
pickDelegator[pusher+readerFrom+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 27
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -114,7 +114,7 @@ func init() {
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+hijacker] = func(d *responseWriterDelegator) delegator { // 28
|
pickDelegator[pusher+readerFrom+hijacker] = func(d *responseWriterDelegator) delegator { // 28
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -122,7 +122,7 @@ func init() {
|
||||||
http.Pusher
|
http.Pusher
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &hijackerDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, hijackerDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 29
|
pickDelegator[pusher+readerFrom+hijacker+closeNotifier] = func(d *responseWriterDelegator) delegator { // 29
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -131,7 +131,7 @@ func init() {
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &hijackerDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, hijackerDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 30
|
pickDelegator[pusher+readerFrom+hijacker+flusher] = func(d *responseWriterDelegator) delegator { // 30
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -140,7 +140,7 @@ func init() {
|
||||||
io.ReaderFrom
|
io.ReaderFrom
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &hijackerDelegator{d}, &flusherDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, hijackerDelegator{d}, flusherDelegator{d}}
|
||||||
}
|
}
|
||||||
pickDelegator[pusher+readerFrom+hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 31
|
pickDelegator[pusher+readerFrom+hijacker+flusher+closeNotifier] = func(d *responseWriterDelegator) delegator { // 31
|
||||||
return struct {
|
return struct {
|
||||||
|
@ -150,7 +150,7 @@ func init() {
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
}{d, &pusherDelegator{d}, &readerFromDelegator{d}, &hijackerDelegator{d}, &flusherDelegator{d}, &closeNotifierDelegator{d}}
|
}{d, pusherDelegator{d}, readerFromDelegator{d}, hijackerDelegator{d}, flusherDelegator{d}, closeNotifierDelegator{d}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue