go-json-rest
go-json-rest copied to clipboard
Add support for setting middlewares that are executed after parsing the path params.
A good use-case would be applying Semver versioning to all endpoints, right now I have to apply a middlewareFunc to every handler, because path params are not present while executing middlewares for obvious resasons.
I'm trying to think about the right API for that. Would a stack of middlewares passed as a parameter of the Router would do ?
I think so, might also be beneficial to have some sort of IfMiddleware that would accept a slice of middlewares/single middleware + be able to check if there's a param in the request, so, for example, if there's version param - let's enable SemVer and so forth.
I guess the same IfMiddleware might do, since it already receives a request object.
I think in this case fine-grained control is crucial, since you would most of the tie want these middlewares only in case a certain param exists.
Router middlewares sound good!