Skip to content

Update watts.rb#5

Open
tablecell wants to merge 1 commit intopete:masterfrom
tablecell:master
Open

Update watts.rb#5
tablecell wants to merge 1 commit intopete:masterfrom
tablecell:master

Conversation

@tablecell
Copy link
Copy Markdown

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 
   }
```
end

# TODO: Problems.
content_type=response.header['Content-Type'] || 'text/html;charset=utf8'
Copy link
Copy Markdown
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.

[
200,
{'Content-Type' => 'text/plain',
{'Content-Type' => >content_type #'text/plain',
Copy link
Copy Markdown
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