Class: Lamby::Handler
- Inherits:
-
Object
- Object
- Lamby::Handler
- Defined in:
- lib/lamby/handler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #base64_encodeable?(hdrs = @headers) ⇒ Boolean
- #body ⇒ Object
- #body64 ⇒ Object
- #call ⇒ Object
- #headers ⇒ Object
-
#initialize(app, event, context, options = {}) ⇒ Handler
constructor
A new instance of Handler.
- #response ⇒ Object
- #set_cookies ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(app, event, context, options = {}) ⇒ Handler
Returns a new instance of Handler.
12 13 14 15 16 17 |
# File 'lib/lamby/handler.rb', line 12 def initialize(app, event, context, = {}) @app = app @event = event @context = context @options = end |
Class Method Details
.call(app, event, context, options = {}) ⇒ Object
6 7 8 |
# File 'lib/lamby/handler.rb', line 6 def call(app, event, context, = {}) new(app, event, context, ).call.response end |
Instance Method Details
#base64_encodeable?(hdrs = @headers) ⇒ Boolean
50 51 52 53 54 55 56 |
# File 'lib/lamby/handler.rb', line 50 def base64_encodeable?(hdrs = @headers) hdrs && ( hdrs['Content-Transfer-Encoding'] == 'binary' || content_encoding_compressed?(hdrs) || hdrs['X-Lamby-Base64'] == '1' ) end |
#body ⇒ Object
38 39 40 41 42 43 |
# File 'lib/lamby/handler.rb', line 38 def body @rbody ||= ''.tap do |rbody| @body.each { |part| rbody << part if part } @body.close if @body.respond_to? :close end end |
#body64 ⇒ Object
58 59 60 |
# File 'lib/lamby/handler.rb', line 58 def body64 Base64.strict_encode64(body) end |
#call ⇒ Object
45 46 47 48 |
# File 'lib/lamby/handler.rb', line 45 def call @response ||= call_app self end |
#headers ⇒ Object
27 28 29 |
# File 'lib/lamby/handler.rb', line 27 def headers @headers end |
#response ⇒ Object
19 20 21 |
# File 'lib/lamby/handler.rb', line 19 def response @response end |
#set_cookies ⇒ Object
31 32 33 34 35 36 |
# File 'lib/lamby/handler.rb', line 31 def return @set_cookies if defined?(@set_cookies) @set_cookies = if @headers && @headers['Set-Cookie'] @headers.delete('Set-Cookie').split("\n") end end |
#status ⇒ Object
23 24 25 |
# File 'lib/lamby/handler.rb', line 23 def status @status end |