sinatra-respond_to icon indicating copy to clipboard operation
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.

Open ashaw opened this issue 15 years ago • 4 comments

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.

ashaw avatar Sep 16 '10 20:09 ashaw

I'm having the same problem. Is there any solution or hack around this?

pelcasandra avatar Jul 02 '12 18:07 pelcasandra

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 avatar Feb 03 '13 13:02 cehoffman

@cehoffman sinatra-contrib offers similar functionality: https://github.com/sinatra/sinatra-contrib/blob/master/lib/sinatra/respond_with.rb

vmoravec avatar Feb 05 '13 09:02 vmoravec

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.

cehoffman avatar Feb 06 '13 20:02 cehoffman