Mux.jl
Mux.jl copied to clipboard
page doesn't work without todict
https://github.com/JuliaWeb/Mux.jl/blob/master/src/routing.jl#L42
page(p::Vector, app...) =
branch(req -> length(p) == length(req[:path]) && matchpath!(p, req), app...)
req[:app]
makes the assumption that the request is a Dict with that key, which is only the case when todict
has been used.
I wonder if it might make sense to just make todict
a built-in middleware, and if necessary just make the original Requst
object a field in the resulting dictionary. @christopher-dG do you have a use-case that requires using the HTTP Request object directly?
I was looking for the simplest path from an HTTP app to a Mux one, so I didn't want to change my handlers. I like working with structs over dicts, it's just preference really.
Given that pretty much all the provided middleware uses the assumed dictionary, it might be a decent chunk of work to add methods for using the Request object directly. There's also the question of, what do you use to pass state around between middleware. Any ideas?