Class: Low::ResponseFactory
- Inherits:
-
Object
- Object
- Low::ResponseFactory
- Defined in:
- lib/responses/response_factory.rb
Class Method Summary collapse
Class Method Details
.file(path:, content_type:) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/responses/response_factory.rb', line 16 def file(path:, content_type:) headers = Protocol::HTTP::Headers.new([['content-type', content_type]]) file = File.open(path, 'rb') body = Protocol::HTTP::Body::File.new(file) Protocol::HTTP::Response.new('HTTP/1.1', 200, headers, body) end |
.html(body:) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/responses/response_factory.rb', line 9 def html(body:) headers = Protocol::HTTP::Headers.new([['content-type', 'text/html']]) body = Protocol::HTTP::Body::Buffered.wrap(body.strip) Protocol::HTTP::Response.new('HTTP/1.1', 200, headers, body) end |
.status(code:) ⇒ Object
24 25 26 27 28 |
# File 'lib/responses/response_factory.rb', line 24 def status(code:) headers = Protocol::HTTP::Headers.new([['content-type', 'text/html']]) Protocol::HTTP::Response.new('HTTP/1.1', code, headers, nil) end |