Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply routes via config #37

Open
ungrim97 opened this issue Feb 16, 2015 · 0 comments
Open

Supply routes via config #37

ungrim97 opened this issue Feb 16, 2015 · 0 comments

Comments

@ungrim97
Copy link
Collaborator

My current use case has the following setup:

MyApp::WAPID::Resource::Note;
MyApp::WAPID::Resource::Notes;
MyApp::Schema::Result::Note;

The Resource classes each contain a single subroutine:

sub forbidden {
    my ($self) = @_;

    my ($username, $password) = $self->request->headers->authorization_basic;

   return 1 unless # some check against basic auth header;
   return 0;
}

This means that the default routes don't work as they use a Generic class for all routes. Whilst I could pass in a new resource_class_for_set item this wouldn't work if I had more than one ResultSource class.

currently in my MyApp.psgi I need to add:

....
routes => [
    WebAPI::DBIC::Route->new(
        path => '/note',
        resource_class => 'MyApp::WAPID::Resource::Notes',
        resource_args => {
            set => $schema->resultset('Note'),
        }
    ),
   .... And again for the item path
]

It would be really useful to have either automatic Resource lookup....and/or definition of all routes in a myapp_routes config or similar. The format could be something like:

{
  "routes" : [
    {
      "path" : "/note",
      "resource_class" : "MyApp::WAPID::Resource::Notes",
      "set" : "Note"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant