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

Get rid of globals to allow for composing routes #24

Closed
rosejn opened this issue Jan 15, 2013 · 2 comments
Closed

Get rid of globals to allow for composing routes #24

rosejn opened this issue Jan 15, 2013 · 2 comments

Comments

@rosejn
Copy link

rosejn commented Jan 15, 2013

Flight is really clean and nicely written, but it would be great if we could compose routes, rather than having them all defined at just the top level. For example, it could work like this:

image_api = Flight::api()

// route requests like: /images/birds/234
image_api::route('@category/@id')

api = Flight::api()
api::route('/images/*', image_api)

Flight::run(api)

In this way an application could be decomposed into a set of APIs, each one of which can be defined in its own way, with its own filters, etc...

@rosejn
Copy link
Author

rosejn commented Jan 15, 2013

Hmmm, I see now that since Flight isn't persistent, it would be reasonable to just put different sub-apis into different directories or files... maybe this isn't necessary.

@mikecao
Copy link
Collaborator

mikecao commented Jan 16, 2013

Not sure what you mean by persistent, but you can simply route different directories to their own handlers:

Flight::route('/images/*', function(){
  // Image API functionality
});

Flight::route('/users/*', function(){
  // User API functionality
});

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

2 participants