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

Bad route selection based on acceptType. #1077

Open
folarte opened this issue Nov 21, 2018 · 1 comment · May be fixed by #1238
Open

Bad route selection based on acceptType. #1077

folarte opened this issue Nov 21, 2018 · 1 comment · May be fixed by #1238

Comments

@folarte
Copy link

folarte commented Nov 21, 2018

I did a test with .

get("/mypath","application/json", MyRoute)

and got my document when acceptin app/json or / with curl. But I got a 404 when accepting text/html.
I wanted to get 406 - Not accepted ( simplifies debugging my clients, I know failure is in the accept header ), so I built an H406 route which just does "throw halt(406)" and added

get("/mypath",H406)

AFTER the previous. As the documentation states routes are processed in order I expected it to match anything not catched.
Testing I got 406 for text/html and 200+doc for app/json, but for the default '*/*' used by curl for accept I got the 406 too. I was expecting for it to match the first route,
Then I went into jedi mode and used the source, and found a route without acceptType gets registered as */*, and the mime parser matches it as preferrable to the first one because it matches exactly with what the client sends.

I'm not familiar enough with spark to assert it is a bug, but I consider this as either a code bug or a documentation one, as I suspect many people will interpret the docs as I did.

( Not a big problem as it can be easily patched or coded around, and not sure of my source analysis being a spark novice. )

@Chauncey-Xxy
Copy link

I am not sure whether it is a bug, but I think it may conflict with the documentation . So I will try to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment