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
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
- .hit(env) ⇒ Object
- .miss(env, reason) ⇒ Object
- .preflight_hit(env) ⇒ Object
- .preflight_miss(env, reason) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#hit ⇒ Object
Returns the value of attribute hit.
166 167 168 |
# File 'lib/rack/cors.rb', line 166 def hit @hit end |
#miss_reason ⇒ Object
Returns the value of attribute miss_reason.
166 167 168 |
# File 'lib/rack/cors.rb', line 166 def miss_reason @miss_reason end |
#preflight ⇒ Object
Returns the value of attribute preflight.
166 167 168 |
# File 'lib/rack/cors.rb', line 166 def preflight @preflight end |
Class Method Details
.hit(env) ⇒ Object
176 177 178 179 180 181 |
# File 'lib/rack/cors.rb', line 176 def self.hit(env) r = Result.new r.preflight = false r.hit = true env[ENV_KEY] = r end |
.miss(env, reason) ⇒ Object
183 184 185 186 187 188 189 |
# File 'lib/rack/cors.rb', line 183 def self.miss(env, reason) r = Result.new r.preflight = false r.hit = false r.miss_reason = reason env[ENV_KEY] = r end |
Instance Method Details
#append_header(headers) ⇒ Object
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/rack/cors.rb', line 206 def append_header(headers) headers[HEADER_KEY] = if hit? preflight? ? 'preflight-hit' : 'hit' else [ (preflight? ? 'preflight-miss' : 'preflight-hit'), miss_reason ].join('; ') end end |
#hit? ⇒ Boolean
168 169 170 |
# File 'lib/rack/cors.rb', line 168 def hit? !!hit end |
#preflight? ⇒ Boolean
172 173 174 |
# File 'lib/rack/cors.rb', line 172 def preflight? !!preflight end |