Class: Liberty::CORS
- Inherits:
-
Object
- Object
- Liberty::CORS
- Defined in:
- lib/liberty/cors.rb,
lib/liberty/cors/middleware.rb
Defined Under Namespace
Classes: Middleware
Constant Summary collapse
- ACCESS_CONTROL_HEADER =
"Access-Control-Allow-Origin"
Class Method Summary collapse
- .access_control_header ⇒ Object
- .config {|_self| ... } ⇒ Object
- .configured? ⇒ Boolean
- .headers ⇒ Object
- .headers=(headers) ⇒ Object
Class Method Details
.access_control_header ⇒ Object
18 19 20 |
# File 'lib/liberty/cors.rb', line 18 def access_control_header headers.slice(ACCESS_CONTROL_HEADER) end |
.config {|_self| ... } ⇒ Object
10 11 12 |
# File 'lib/liberty/cors.rb', line 10 def config yield(self) end |
.configured? ⇒ Boolean
14 15 16 |
# File 'lib/liberty/cors.rb', line 14 def configured? !@headers.nil? && !@headers.empty? end |
.headers ⇒ Object
22 23 24 |
# File 'lib/liberty/cors.rb', line 22 def headers @headers ||= {} end |
.headers=(headers) ⇒ Object
26 27 28 29 30 |
# File 'lib/liberty/cors.rb', line 26 def headers=(headers) raise ArgumentError.new("Expected headers to be a Hash, received a #{headers.class} instead") unless headers.is_a?(Hash) @headers = headers end |