Class: FDK::HTTPContext
- Inherits:
-
Object
- Object
- FDK::HTTPContext
- Defined in:
- lib/fdk/context.rb
Overview
Represents the context data (inbound && outbound) for the execution passed as HTTP headers
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#response_headers ⇒ Object
readonly
Returns the value of attribute response_headers.
Instance Method Summary collapse
-
#initialize(ctx) ⇒ HTTPContext
constructor
A new instance of HTTPContext.
- #method ⇒ Object
- #request_url ⇒ Object
- #status_code=(val) ⇒ Object
Constructor Details
#initialize(ctx) ⇒ HTTPContext
Returns a new instance of HTTPContext.
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/fdk/context.rb', line 127 def initialize(ctx) fn_http_h_ = "fn-http-h-" @ctx = ctx http_headers = {} ctx.headers.each do |k, v| http_headers[k.sub(fn_http_h_, "")] = v if k.downcase.start_with?(fn_http_h_) end @headers = InHeaders.new(http_headers, nil) @response_headers = OutHeaders.new(ctx.response_headers, ->(s) { fn_http_h_ + s }) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
125 126 127 |
# File 'lib/fdk/context.rb', line 125 def headers @headers end |
#response_headers ⇒ Object (readonly)
Returns the value of attribute response_headers.
125 126 127 |
# File 'lib/fdk/context.rb', line 125 def response_headers @response_headers end |
Instance Method Details
#method ⇒ Object
142 143 144 |
# File 'lib/fdk/context.rb', line 142 def method @ctx.headers["fn-http-method"] end |
#request_url ⇒ Object
138 139 140 |
# File 'lib/fdk/context.rb', line 138 def request_url @ctx.headers["fn-http-request-url"] end |
#status_code=(val) ⇒ Object
146 147 148 |
# File 'lib/fdk/context.rb', line 146 def status_code=(val) @ctx.response_headers["fn-http-status"] = val.to_i end |