forked from DataDog/dd-trace-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace_gen.go
126 lines (120 loc) · 3.19 KB
/
trace_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2020 Datadog, Inc.
// Code generated by make_responsewriter.go DO NOT EDIT
package httputil
import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"net/http"
)
// wrapResponseWriter wraps an underlying http.ResponseWriter so that it can
// trace the http response codes. It also checks for various http interfaces
// (Flusher, Pusher, CloseNotifier, Hijacker) and if the underlying
// http.ResponseWriter implements them it generates an unnamed struct with the
// appropriate fields.
//
// This code is generated because we have to account for all the permutations
// of the interfaces.
func wrapResponseWriter(w http.ResponseWriter, span ddtrace.Span) http.ResponseWriter {
hFlusher, okFlusher := w.(http.Flusher)
hPusher, okPusher := w.(http.Pusher)
hCloseNotifier, okCloseNotifier := w.(http.CloseNotifier)
hHijacker, okHijacker := w.(http.Hijacker)
w = newResponseWriter(w, span)
switch {
case okFlusher && okPusher && okCloseNotifier && okHijacker:
w = struct {
http.ResponseWriter
http.Flusher
http.Pusher
http.CloseNotifier
http.Hijacker
}{w, hFlusher, hPusher, hCloseNotifier, hHijacker}
case okFlusher && okPusher && okCloseNotifier:
w = struct {
http.ResponseWriter
http.Flusher
http.Pusher
http.CloseNotifier
}{w, hFlusher, hPusher, hCloseNotifier}
case okFlusher && okPusher && okHijacker:
w = struct {
http.ResponseWriter
http.Flusher
http.Pusher
http.Hijacker
}{w, hFlusher, hPusher, hHijacker}
case okFlusher && okCloseNotifier && okHijacker:
w = struct {
http.ResponseWriter
http.Flusher
http.CloseNotifier
http.Hijacker
}{w, hFlusher, hCloseNotifier, hHijacker}
case okPusher && okCloseNotifier && okHijacker:
w = struct {
http.ResponseWriter
http.Pusher
http.CloseNotifier
http.Hijacker
}{w, hPusher, hCloseNotifier, hHijacker}
case okFlusher && okPusher:
w = struct {
http.ResponseWriter
http.Flusher
http.Pusher
}{w, hFlusher, hPusher}
case okFlusher && okCloseNotifier:
w = struct {
http.ResponseWriter
http.Flusher
http.CloseNotifier
}{w, hFlusher, hCloseNotifier}
case okFlusher && okHijacker:
w = struct {
http.ResponseWriter
http.Flusher
http.Hijacker
}{w, hFlusher, hHijacker}
case okPusher && okCloseNotifier:
w = struct {
http.ResponseWriter
http.Pusher
http.CloseNotifier
}{w, hPusher, hCloseNotifier}
case okPusher && okHijacker:
w = struct {
http.ResponseWriter
http.Pusher
http.Hijacker
}{w, hPusher, hHijacker}
case okCloseNotifier && okHijacker:
w = struct {
http.ResponseWriter
http.CloseNotifier
http.Hijacker
}{w, hCloseNotifier, hHijacker}
case okFlusher:
w = struct {
http.ResponseWriter
http.Flusher
}{w, hFlusher}
case okPusher:
w = struct {
http.ResponseWriter
http.Pusher
}{w, hPusher}
case okCloseNotifier:
w = struct {
http.ResponseWriter
http.CloseNotifier
}{w, hCloseNotifier}
case okHijacker:
w = struct {
http.ResponseWriter
http.Hijacker
}{w, hHijacker}
}
return w
}