public function register(Container $app)
    {
        $app["cors.allowOrigin"] = "*"; // Defaults to all
        $app["cors.allowMethods"] = null; // Defaults to all
        $app["cors.allowHeaders"] = null; // Defaults to all
        $app["cors.maxAge"] = null;
        $app["cors.allowCredentials"] = null;
        $app["cors.exposeHeaders"] = null;

        $app["allow"] = $app->protect(new Allow());

        $app["options"] = $app->protect(function ($subject) use ($app) {
            $optionsController = function () {
                return Response::create("", 204);
            };

            if ($subject instanceof Controller) {
                $optionsRoute = $app->options($subject->getRoute()->getPath(), $optionsController)
                    ->after($app["allow"]);
            } else {
                $optionsRoute = $subject->options("{path}", $optionsController)
                    ->after($app["allow"])
                    ->assert("path", ".*");
            }

            return $optionsRoute;
        });

        $app["cors-enabled"] = $app->protect(function ($subject, $config = []) use ($app) {
            $optionsController = $app["options"]($subject);
            $cors = new Cors($config);

            if ($subject instanceof Controller) {
                $optionsController->after($cors);
            }

            $subject->after($cors);

            return $subject;
        });

        $app["cors"] = function () use ($app) {
            $app["options"]($app);
            return new Cors();
        };
    }
public function register(Container $app)
    {
        $app["cors.allowOrigin"] = "*"; // Defaults to all
        $app["cors.allowMethods"] = null; // Defaults to all
        $app["cors.allowHeaders"] = null; // Defaults to all
        $app["cors.maxAge"] = null;
        $app["cors.allowCredentials"] = null;
        $app["cors.exposeHeaders"] = null;

        $app["allow"] = $app->protect(new Allow());

        $app["options"] = $app->protect(function ($subject) use ($app) {
            $optionsController = function () {
                return Response::create("", 204);
            };

            if ($subject instanceof Controller) {
                $optionsRoute = $app->options($subject->getRoute()->getPath(), $optionsController)
                    ->after($app["allow"]);
            } else {
                $optionsRoute = $subject->options("{path}", $optionsController)
                    ->after($app["allow"])
                    ->assert("path", ".*");
            }

            return $optionsRoute;
        });

        $app["cors-enabled"] = $app->protect(function ($subject, $config = []) use ($app) {
            $optionsController = $app["options"]($subject);
            $cors = new Cors($config);

            if ($subject instanceof Controller) {
                $optionsController->after($cors);
            }

            $subject->after($cors);

            return $subject;
        });

        $app["cors"] = function () use ($app) {
            $app["options"]($app);
            return new Cors();
        };
    }
public function register ( Container $ app ) { $ app [ "cors.allowOrigin" ] = "*" ; // Defaults to all $ app [ "cors.allowMethods" ] = null ; // Defaults to all $ app [ "cors.allowHeaders" ] = null ; // Defaults to all $ app [ "cors.maxAge" ] = null ; $ app [ "cors.allowCredentials" ] = null ; $ app [ "cors.exposeHeaders" ] = null ; $ app [ "allow" ] = $ app -> protect ( new Allow ( ) ) ; $ app [ "options" ] = $ app -> protect ( function ( $ subject ) use ( $ app ) { $ optionsController = function ( ) { return Response :: create ( "" , 204 ) ; } ; if ( $ subject instanceof Controller ) { $ optionsRoute = $ app -> options ( $ subject -> getRoute ( ) -> getPath ( ) , $ optionsController ) -> after ( $ app [ "allow" ] ) ; } else { $ optionsRoute = $ subject -> options ( "{path}" , $ optionsController ) -> after ( $ app [ "allow" ] ) -> assert ( "path" , ".*" ) ; } return $ optionsRoute ; } ) ; $ app [ "cors-enabled" ] = $ app -> protect ( function ( $ subject , $ config = [ ] ) use ( $ app ) { $ optionsController = $ app [ "options" ] ( $ subject ) ; $ cors = new Cors ( $ config ) ; if ( $ subject instanceof Controller ) { $ optionsController -> after ( $ cors ) ; } $ subject -> after ( $ cors ) ; return $ subject ; } ) ; $ app [ "cors" ] = function ( ) use ( $ app ) { $ app [ "options" ] ( $ app ) ; return new Cors ( ) ; } ; }
Register the cors function and set defaults

@param Container $app
Register the cors function and set defaults