Class: Rack::Cors::Result
- Inherits:
-
Object
- Object
- Rack::Cors::Result
- Defined in:
- lib/rack/cors.rb
Constant Summary collapse
- HEADER_KEY =
'X-Rack-CORS'.freeze
- MISS_NO_ORIGIN =
'no-origin'.freeze
- MISS_NO_PATH =
'no-path'.freeze
- MISS_NO_METHOD =
'no-method'.freeze
- MISS_DENY_METHOD =
'deny-method'.freeze
- MISS_DENY_HEADER =
'deny-header'.freeze
Instance Attribute Summary collapse
-
#hit ⇒ Object
Returns the value of attribute hit.
-
#miss_reason ⇒ Object
Returns the value of attribute miss_reason.
-
#preflight ⇒ Object
Returns the value of attribute preflight.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#hit ⇒ Object
Returns the value of attribute hit.
217 218 219 |
# File 'lib/rack/cors.rb', line 217 def hit @hit end |
#miss_reason ⇒ Object
Returns the value of attribute miss_reason.
217 218 219 |
# File 'lib/rack/cors.rb', line 217 def miss_reason @miss_reason end |
#preflight ⇒ Object
Returns the value of attribute preflight.
217 218 219 |
# File 'lib/rack/cors.rb', line 217 def preflight @preflight end |
Class Method Details
.hit(env) ⇒ Object
232 233 234 235 236 237 |
# File 'lib/rack/cors.rb', line 232 def self.hit(env) r = Result.new r.preflight = false r.hit = true env[RACK_CORS] = r end |
Instance Method Details
#append_header(headers) ⇒ Object
254 255 256 257 258 259 260 261 262 263 |
# File 'lib/rack/cors.rb', line 254 def append_header(headers) headers[HEADER_KEY] = if hit? preflight? ? 'preflight-hit' : 'hit' else [ (preflight? ? 'preflight-miss' : 'miss'), miss_reason ].join('; ') end end |
#hit? ⇒ Boolean
219 220 221 |
# File 'lib/rack/cors.rb', line 219 def hit? !!hit end |
#miss(reason) ⇒ Object
227 228 229 230 |
# File 'lib/rack/cors.rb', line 227 def miss(reason) self.hit = false self.miss_reason = reason end |
#preflight? ⇒ Boolean
223 224 225 |
# File 'lib/rack/cors.rb', line 223 def preflight? !!preflight end |