-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Override content type #412
Comments
Might want to bring up things like this on the list. I think all you need to do is set content type with Reopen with a repro if this is still an issue. |
+1. Adding |
Confirming it's a bug. |
@dblock thank you |
Fixed in dce96e1, please let me know if that works. There's a workaround for existing versions, do |
Anyway thank you because I applied |
I want to make sure this does work when the next version is released. Double-check that you're pointing to Grape HEAD. I added a demo to my little rack app, dblock/grape-on-rack@39a166e and it worked OK. You can monkey patch the formatter to see what's going on. module Grape
module Middleware
class Formatter < Base
def after
status, headers, bodies = *@app_response
puts "headers: #{headers}"
puts "content type: #{headers['Content-Type']}"
puts "mime type: #{mime_types[headers['Content-Type']]}"
puts "api format: #{env['api.format']}"
raise "stop here"
end
end
end
end The above should have the correct mime type, |
done
Thanks. I'll do |
HEAD
HEAD +
|
Do you have a |
nope. Added. See output: HEAD +
|
Sorry, change |
Also you may want to look at API class https://github.com/gitlabhq/gitlabhq/blob/master/lib/api/api.rb |
HEAD +
|
I looked at your code. Here's my diff: Gemfilegem "grape", :git => "https://github.com/intridea/grape.git" api.rb format :json
content_type :txt, 'text/plain'
get 'foo' do
content_type 'text/plain'
"hello world"
end spec/requests/api/foo_spec.rbrequire 'spec_helper'
describe API::API do
include ApiHelpers
it "foo" do
get api("/foo")
response.body.should == "hello world"
end
end This works. What do you have? |
Ok I can confirm it works now. Thank you very much! I owe you a 🍺 :) |
In a project I'm working on we are having some issues with a recent change (#347). We have a JSON API that has some calls that return RAW content (raw blobs of code). Prior to #347, this was no problem. But now, it puts the entire content in quotes and all new lines are encoded as \n.
Is there a way to override the content type for certain APIs so that this type of content is delivered in plain text? Thanks.
The text was updated successfully, but these errors were encountered: