Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page doesn't work without todict #91

Open
christopher-dG opened this issue Apr 12, 2019 · 3 comments
Open

page doesn't work without todict #91

christopher-dG opened this issue Apr 12, 2019 · 3 comments

Comments

@christopher-dG
Copy link
Member

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.

@jpsamaroo
Copy link
Collaborator

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?

@christopher-dG
Copy link
Member Author

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.

@jpsamaroo
Copy link
Collaborator

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?

@cmcaine cmcaine mentioned this issue Dec 20, 2020
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants