stash / Feersum

A PSGI engine for Perl based on EV/libev
http://search.cpan.org/~stash/Feersum/
74 stars 15 forks source link

Add support for `OPTIONS` http method #20

Closed mgreter closed 9 years ago

mgreter commented 9 years ago

Not sure why support for this was not yet added ... the changes seem trivial. I needed it to enable correct cors headers for the OPTIONS request from UA.

Just to be complete, here to part from the psgi application:

my @allowed_headers = ('X-NAMESPACE-OPTION-1', ...);
my @allowed_methods = ('OPTIONS', 'POST', 'GET', 'HEAD');
if ($request->method eq 'OPTIONS') {
    return [
        '200',
        [
            'Allow' => join(", ", @allowed_methods),
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Headers' => join(", ", @allowed_headers),
            'Access-Control-Allow-Methods' => join(", ", @allowed_methods),
        ],
        []
    ];
}

Best regards Marcel Greter

audreyt commented 9 years ago

Thanks! Released to CPAN as of 1.403.