Add ConstructorFunc / MiddlewareFunc#32
Conversation
|
Adding a test case is a TODO, but I'd first appreciate confirmation that the idea is acceptable. |
|
Review status: 0 of 1 files reviewed at latest revision, 1 unresolved discussion. chain.go, line 33 [r1] (raw file):
Just a code beautification, avoid 'var h' and use anonymous function call directly. Consider 'return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { Comments from Reviewable |
MiddlewareFunc defines a standard signature for a http.HandlerFunc which accepts a chained http.Handler to invoke. ConstructorFunc supplies an adapter for converting a MiddlewareFunc into a Constructor. This is most useful for building middleware with bound parameters via closures.
d6e1832 to
8f8931b
Compare
|
Apologies for the delay. Reviewing the tests, switching over PTAL. Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion. chain.go, line 33 [r1] (raw file):
|
|
Bueller ? |
|
+1 |
1 similar comment
|
+1 |
|
Sorry for the delay and I hate to be bikeshedding at this point, but one thing I'd like to do with this is clear separation of this model of middleware as an "adapter". As the naming stands now,
|
|
Look at https://godoc.org/github.com/go-web/httpmux#Middleware and https://godoc.org/github.com/go-web/httpmux#MiddlewareFunc. And github search here: https://github.com/search?utf8=%E2%9C%93&q=MiddlewareFunc+language%3Ago&type=Code&ref=searchresults I think better names are MiddlewareFunc and Middleware, but it wil not be backwards compatibile. |
MiddlewareFunc defines a standard signature for a http.HandlerFunc which
accepts a chained http.Handler to invoke. ConstructorFunc supplies an
adapter for converting a MiddlewareFunc into a Constructor. This is most
useful for building middleware with bound parameters via closures.
This change is