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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/watts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.


case resp
when nil
response
Expand All @@ -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.

'Content-Length' => resp.bytesize.to_s,
},
[resp]
Expand Down