Open hantuzun opened 7 years ago
Something is fishy. Try to build a spec in Grape for this?
@dblock the behavior above is expected because Rack::Cascade
catches only the responses with 404/405 status code but the grape middleware formatter returns the response with 406 status code(when explicit json
format is provided but the request has a different type). so Rack::Cascade.new([API, BAPI], 404..406)
might help.
But I have a different problem here :tired_face:
When format :json is removed, it returns {"bapi": "bapi"} as expected.
I cannot repeat this on master branch.
@hantuzun which grape
version is used?
Thanks guys!
@dmitry; I experienced that with grape 0.10.1.
I achieved what I wanted by swapping the endpoints in cascade constructor array like: run Rack::Cascade.new [BAPI, API]
. It worked "as I expected" in that case – serving two methods with different content types.
What's the best practice for serving two sets of methods that accepts different content-types?
0.10.0 is really old, we're on 0.18.0, just want to make sure we're not fixing something that's fixed long time ago
Oh, I don't know why bundler installed that. Thanks for the notice!
I'll try to reproduce the error on the latest release.
We have two endpoints, one accepts
application/json
content-type, the other acceptstext/plain
. They live together. However, whenformat :json
is included in one of our API's the other one is effected as well.Consider the example below:
In this case,
POST /v1/users
returns{"error":"The requested content-type 'text/plain' is not supported."}
. Whenformat :json
is removed, it returns{"bapi": "bapi"}
as expected.