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

response.headers['Content-Type'] ="text/html;" return Content-Type: text/plain #4

Open
tablecell opened this issue Sep 24, 2021 · 3 comments

Comments

@tablecell
Copy link

require 'watts'

class Simple < Watts::App
	class EZResource < Watts::Resource
	
		get { 
		response.headers['Content-Type'] ="text/html;charset=utf-8"

		#"Hello, World!\n" 
		ERB.new(File.read("view/test.erb")).result
		
		}
	end

	resource('/', EZResource)
end

curl http://localhost:9292/
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 14

@mustmodify
Copy link

mustmodify commented Jan 30, 2023

@pete I'm also having this issue... any thoughts? I'm guessing, based on a pattern of code like this that I would have to patch Watts to send the right header.

@mustmodify
Copy link

This works, but it's a suboptimal interface IMO

  class BookDropResource < Watts::Resource
    get {
      [
        200,
        {'Content-Type' => 'text/html'},
        [ERB.new(File.read("#{__dir__}/views/book_drop_index.html.erb")).result]
      ]
    }
  end

@mustmodify
Copy link

mustmodify commented Feb 5, 2023

Solution can be found in PR 5

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

No branches or pull requests

2 participants