class Amber::Pipe::CORS

Defined in:

amber/pipes/cors.cr

Constant Summary

ALLOW_HEADERS = ["Accept", "Content-Type"] of ::String
ALLOW_METHODS = ["POST", "PUT", "PATCH", "DELETE"] of ::String
FORBIDDEN = "Forbidden for invalid origins, methods or headers"

Constructors

Instance Method Summary

Instance methods inherited from class Amber::Pipe::Base

call(context : HTTP::Server::Context) call

Constructor Detail

def self.new(origins : OriginList = OriginList {"*"}, methods : Array(String) = ALLOW_METHODS, headers : Array(String) = ALLOW_HEADERS, credentials : Bool = false, max_age : Int32 | Nil = 0, expose_headers : Array(String) | Nil = nil, vary : String | Nil = nil) #

[View source]
def self.new(origins : Array(String), methods = ALLOW_METHODS, headers = ALLOW_HEADERS, credentials = false, max_age : Int32 | Nil = 0, expose_headers : Array(String) | Nil = nil, vary : String | Nil = nil) #

Lists plain origins. An app that uses this form links no regex engine.


[View source]
def self.new(origins : OriginType, methods = ALLOW_METHODS, headers = ALLOW_HEADERS, credentials = false, max_age : Int32 | Nil = 0, expose_headers : Array(String) | Nil = nil, vary : String | Nil = nil) #

Accepts Regex origins. This overload compiles only in an app that calls it, so an app that lists plain origins links no regex engine.


[View source]

Instance Method Detail

def call(context : HTTP::Server::Context) #
Description copied from class Amber::Pipe::Base

Execution of this handler.


[View source]
def credentials : Bool #

[View source]
def credentials=(credentials : Bool) #

[View source]
def forbidden(context) #

[View source]
def headers : Array(String) #

[View source]
def headers=(headers : Array(String)) #

[View source]
def max_age : Int32? #

[View source]
def max_age=(max_age : Int32 | Nil) #

[View source]
def methods : Array(String) #

[View source]
def methods=(methods : Array(String)) #

[View source]
def origins : Array(String -> Bool | String) #

[View source]
def origins=(origins : Array(String -> Bool | String)) #

[View source]