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

Update watts.rb #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update watts.rb #5

wants to merge 1 commit into from

Conversation

tablecell
Copy link

add custom response.header ['Content-Type'] like 'application/json'

   post {
       response.header['Content-Type']= 'application/json'
       request.params.to_hash.to_json 
   }

add custom response.header ['Content-Type'] like  'application/json'
```RUBY
   post {
       response.header['Content-Type']= 'application/json'
       request.params.to_hash.to_json 
   }
```
@@ -236,6 +236,8 @@ def self.inherited base
end

# TODO: Problems.
content_type=response.header['Content-Type'] || 'text/html;charset=utf8'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main issue with this change is that it creates a Rack::Response even if it doesn't exist. I was thinking about this, it's come up a couple of times. I think what would probably be best to do is add something like Watts::Resource#default_content_type or possibly Watts::Resource#default_headers so that it can be overridden in subclasses.

@@ -245,7 +247,7 @@ def self.inherited base
resp = resp.to_s
[
200,
{'Content-Type' => 'text/plain',
{'Content-Type' => >content_type #'text/plain',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a syntax error, if I'm not mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants