The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Dancer::Plugin::CORS::Sharing - Helper class for sharing method

VERSION

version 0.13

DESCRIPTION

In order to use many rules with many routes, this helpers class helps you to organize yourself.

SYNOPSIS

    use Dancer::Plugin::CORS;

        sharing->rule(
                origin => ...,
                credentials => 1
        );
        
        $route = post '/' => sub { ... };
        
        sharing->add($route);

METHODS

new

A convient way is to use the implicit form of the module. This means you don't have to call new() self, just start with defining rules and add routes.

When you want more than one ruleset, obtain a new instance by calling new():

        my $sharing = sharing->new;
        $sharing->rule(...);
        $sharing->add(...);

rule(%options)

This method defines a optionset. See Dancer::Plugin::CORS::share for a explaination of valid options.

add(@routes)

This method finally calls Dancer::Plugin::CORS::share for any route. @routes maybe a list of arrayrefs of Dancer::Route objects or paths.

Note: Dancer::Plugin::CRUD::resource returns a hash instead of a list. Use values() to obtain the route objects:

        sharing->add(values(resource(...)));

clear

This method clears all previously defined rules.

SEE ALSO

1;

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/zurborg/libdancer-plugin-cors-perl/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

David Zurborg <zurborg@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by David Zurborg.

This is free software, licensed under:

  The ISC License