Cors
    
            
            in package
            
        
    
    
    
Cross-Origin Resource Sharing (CORS)
Tags
Table of Contents
Properties
- 
    $config
    
                         : array{allowedOrigins: list, allowedOriginsPatterns: list , supportsCredentials: bool, allowedHeaders: list , exposedHeaders: list , allowedMethods: list , maxAge: int} 
Methods
- __construct() : mixed
- addResponseHeaders() : ResponseInterface
- Adds CORS headers to the Response.
- factory() : self
- Creates a new instance by config name.
- handlePreflightRequest() : ResponseInterface
- Handles the preflight request, and returns the response.
- hasResponseHeaders() : bool
- Check if response headers were set
- isPreflightRequest() : bool
- Whether if the request is a preflight request.
- checkWildcard() : void
- checkWildcardAndCredentials() : void
- setAllowCredentials() : void
- setAllowHeaders() : void
- setAllowMaxAge() : void
- setAllowMethods() : void
- setAllowOrigin() : void
- setExposeHeaders() : void
Properties
$config
        private
            array{allowedOrigins: list, allowedOriginsPatterns: list, supportsCredentials: bool, allowedHeaders: list, exposedHeaders: list, allowedMethods: list, maxAge: int}     
    $config
     = ['allowedOrigins' => [], 'allowedOriginsPatterns' => [], 'supportsCredentials' => false, 'allowedHeaders' => [], 'exposedHeaders' => [], 'allowedMethods' => [], 'maxAge' => 7200]
    
    
    
    
    
Methods
__construct()
    public
                    __construct([array{allowedOrigins?: list, allowedOriginsPatterns?: list, supportsCredentials?: bool, allowedHeaders?: list, exposedHeaders?: list, allowedMethods?: list, maxAge?: int}|Cors|null      $config = null ]) : mixed
    Parameters
- 
                $config
                : array{allowedOrigins?: list, allowedOriginsPatterns?: list = null, supportsCredentials?: bool, allowedHeaders?: list , exposedHeaders?: list , allowedMethods?: list , maxAge?: int}|Cors|null 
addResponseHeaders()
Adds CORS headers to the Response.
    public
                    addResponseHeaders(RequestInterface $request, ResponseInterface $response) : ResponseInterface
    Parameters
- $request : RequestInterface
- $response : ResponseInterface
Return values
ResponseInterfacefactory()
Creates a new instance by config name.
    public
            static        factory([string $configName = 'default' ]) : self
    Parameters
- $configName : string = 'default'
Return values
selfhandlePreflightRequest()
Handles the preflight request, and returns the response.
    public
                    handlePreflightRequest(RequestInterface $request, ResponseInterface $response) : ResponseInterface
    Parameters
- $request : RequestInterface
- $response : ResponseInterface
Return values
ResponseInterfacehasResponseHeaders()
Check if response headers were set
    public
                    hasResponseHeaders(RequestInterface $request, ResponseInterface $response) : bool
    Parameters
- $request : RequestInterface
- $response : ResponseInterface
Return values
boolisPreflightRequest()
Whether if the request is a preflight request.
    public
                    isPreflightRequest(IncomingRequest $request) : bool
    Parameters
- $request : IncomingRequest
Return values
boolcheckWildcard()
    private
                    checkWildcard(string $name, int $count) : void
    Parameters
- $name : string
- $count : int
checkWildcardAndCredentials()
    private
                    checkWildcardAndCredentials(string $name, string $header) : void
    Parameters
- $name : string
- $header : string
setAllowCredentials()
    private
                    setAllowCredentials(ResponseInterface $response) : void
    Parameters
- $response : ResponseInterface
setAllowHeaders()
    private
                    setAllowHeaders(ResponseInterface $response) : void
    Parameters
- $response : ResponseInterface
setAllowMaxAge()
    private
                    setAllowMaxAge(ResponseInterface $response) : void
    Parameters
- $response : ResponseInterface
setAllowMethods()
    private
                    setAllowMethods(ResponseInterface $response) : void
    Parameters
- $response : ResponseInterface
setAllowOrigin()
    private
                    setAllowOrigin(RequestInterface $request, ResponseInterface $response) : void
    Parameters
- $request : RequestInterface
- $response : ResponseInterface
setExposeHeaders()
    private
                    setExposeHeaders(ResponseInterface $response) : void
    Parameters
- $response : ResponseInterface