@@ -42,9 +42,9 @@ type ResourceHandler struct {
42
42
43
43
// Optional global middlewares that can be used to wrap the all REST endpoints.
44
44
// They are used in the defined order, the first wrapping the second, ...
45
+ // They are run pre REST routing, request.PathParams is not set yet.
45
46
// They can be used for instance to manage CORS or authentication.
46
47
// (see the CORS example in go-json-rest-example)
47
- // They are run pre REST routing, request.PathParams is not set yet.
48
48
PreRoutingMiddlewares []Middleware
49
49
50
50
// Custom logger for the access log,
@@ -96,9 +96,9 @@ func (rh *ResourceHandler) SetRoutes(routes ...*Route) error {
96
96
return nil
97
97
}
98
98
99
+ // Instantiate all the middlewares.
99
100
func (rh * ResourceHandler ) instantiateMiddlewares () {
100
101
101
- // instantiate all the middlewares
102
102
middlewares := []Middleware {
103
103
// log as the first, depend on timer and recorder.
104
104
& logMiddleware {
@@ -132,11 +132,11 @@ func (rh *ResourceHandler) instantiateMiddlewares() {
132
132
)
133
133
134
134
rh .handlerFunc = rh .adapter (
135
- wrapMiddlewares (middlewares , rh .app ()),
135
+ WrapMiddlewares (middlewares , rh .app ()),
136
136
)
137
137
}
138
138
139
- // Middleware that handles the transition between http and rest objects.
139
+ // Handle the transition between http and rest objects.
140
140
func (rh * ResourceHandler ) adapter (handler HandlerFunc ) http.HandlerFunc {
141
141
return func (origWriter http.ResponseWriter , origRequest * http.Request ) {
142
142
0 commit comments