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

add URI based routing to the class interface #53

Open
gfoster opened this issue Feb 17, 2012 · 0 comments
Open

add URI based routing to the class interface #53

gfoster opened this issue Feb 17, 2012 · 0 comments

Comments

@gfoster
Copy link

gfoster commented Feb 17, 2012

the @add_route decorator works fine for doing procedural handlers, but if I want a class based handler that uses URI based routing instead of method based routing it doesn't work so hot.

I can catch all the calls in the get method, pick apart the route and figure out how to route them appropriately to different methods to handle different subroutes, but I'd rather be able to just do URI based invocations (similar to the way cherrypy works).

Is the functionality already in there and I'm not catching it? The add_route decorator isn't part of the WebMessageHandler class, so I haven't been able to do it that way and instead I've created an introspective get method that looks for an appropriate method to call based upon the name of the incoming route and the method (if it has a GET request to /foo/bar it looks for a "GET_foo_bar" method) but I am not going to keep going this way.

If there's already functionality for this can someone point it out to me and if not, I'll simply add in the add_route decorator functionality to the WebMessageHandler itself so you can do something like this:

class FooHandler(WebMessageHandler):

   @add_route('/foo/bar', method='GET')
   def blah(self):
      self.set_body("You did a GET request to /foo/bar")
      return self.render

so it operates similarly to the procedural decorator version.

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