sinatra-respond_to
sinatra-respond_to copied to clipboard
Unable to create params with dots in them because sinatra-respond_to always assumes they refer to mime-type.
If I explicitly set a route to capture something into params, such as
get %r{/api/url/(.+[^?])} do
#action
end
and I request something like /api/url/http://someurl.com/somepage.php, that regex should capture dots into params[:captures]. Sinatra-respond_to chokes on the dot and throws: Unknown media type php Try registering the extension with a mime type. Route patterns should take precedence over mime-type sniffing.
I'm having the same problem. Is there any solution or hack around this?
I'd be interested in knowing if you guys came up with workarounds for this.
The only solution I have come up with is using a ?format=<expected format> on the requests. This will override the path_info rewriting.
@cehoffman sinatra-contrib offers similar functionality: https://github.com/sinatra/sinatra-contrib/blob/master/lib/sinatra/respond_with.rb
I've seen this alternative before. I hadn't looked too closely at it, but now I see the main difference in what types of paths each offer.
Perhaps there is room for a configuration setting that disables using mime detection by extension at the application level. Doing it at the individual route level would be rather complicated in the current sinatra setup.