@@ -19,6 +19,12 @@ type modulesInterface interface {
19
19
Auth () * auth.Module
20
20
}
21
21
22
+ var httpClient = http.Client {
23
+ CheckRedirect : func (req * http.Request , via []* http.Request ) error {
24
+ return http .ErrUseLastResponse
25
+ },
26
+ }
27
+
22
28
// HandleRoutes handles incoming http requests and routes them according to the configured rules.
23
29
func (r * Routing ) HandleRoutes (modules modulesInterface ) http.HandlerFunc {
24
30
return func (writer http.ResponseWriter , request * http.Request ) {
@@ -36,7 +42,7 @@ func (r *Routing) HandleRoutes(modules modulesInterface) http.HandlerFunc {
36
42
return
37
43
}
38
44
39
- token , auth , status , err := r .modifyRequest (request .Context (), modules , route , request )
45
+ token , claims , status , err := r .modifyRequest (request .Context (), modules , route , request )
40
46
if err != nil {
41
47
writer .WriteHeader (status )
42
48
_ = json .NewEncoder (writer ).Encode (map [string ]string {"error" : err .Error ()})
@@ -59,7 +65,7 @@ func (r *Routing) HandleRoutes(modules modulesInterface) http.HandlerFunc {
59
65
}
60
66
61
67
// TODO: Use http2 client if that was the incoming request protocol
62
- response , err := http . DefaultClient .Do (request )
68
+ response , err := httpClient .Do (request )
63
69
if err != nil {
64
70
writer .WriteHeader (http .StatusInternalServerError )
65
71
_ = json .NewEncoder (writer ).Encode (map [string ]string {"error" : err .Error ()})
@@ -68,7 +74,7 @@ func (r *Routing) HandleRoutes(modules modulesInterface) http.HandlerFunc {
68
74
}
69
75
defer utils .CloseTheCloser (response .Body )
70
76
71
- if err := r .modifyResponse (request .Context (), response , route , token , auth ); err != nil {
77
+ if err := r .modifyResponse (request .Context (), response , route , token , claims ); err != nil {
72
78
writer .WriteHeader (http .StatusInternalServerError )
73
79
_ = json .NewEncoder (writer ).Encode (map [string ]string {"error" : err .Error ()})
74
80
return
@@ -128,7 +134,7 @@ func setRequest(ctx context.Context, request *http.Request, route *config.Route,
128
134
return nil
129
135
}
130
136
131
- func prepareHeaders (ctx context. Context , headers config.Headers , state map [string ]interface {}) config.Headers {
137
+ func prepareHeaders (headers config.Headers , state map [string ]interface {}) config.Headers {
132
138
out := make ([]config.Header , len (headers ))
133
139
for i , header := range headers {
134
140
// First create a new header object
0 commit comments