pyGrowler / Growler

A micro web-framework using asyncio coroutines and chained middleware.
http://www.growler.rocks
Apache License 2.0
686 stars 29 forks source link

routes using @routerclass decorator #7

Closed foodaemon closed 7 years ago

foodaemon commented 8 years ago

Very awesome project and i appreciate your great work. I am liking the project but the docstring based routing seems a bit unusual to me. Are you guys planning to keep it or change it to more simpler straight forward approach like other framework like falcon (another python framework to build REST API) does? For the newbie programmers, would that be confusing and harder to debug?

akubera commented 8 years ago

I hadn't heard of Falcon before, thanks for pointing that project out.

The docstring routing is unusual, but I thought that was a good thing. It was inspired by the parsing rules in PLY, so there is precedence for using docstrings as more than metadata.

Does Falcon allow multiple mountpoints on a single object? It looks like you create an object and fix it to one point in the API, and you can differentiate HTTP verbs with methods on_get(...), on_post(...).

The alternative is using a bunch of decorators to specify the mount point

@mountpoint('/foo/bar')
def get_foobar(self, req, res):
    ...

vs

def get_foobar(self, req, res):
    """/foo/bar"""
    ...

I never really got around to thinking about how to implement @mountpoint; I invite you to (or anyone reading this ;-)) to fork growler and try to figure it out.

foodaemon commented 8 years ago

I believe falcon does not support multiple mount point for a single object. The concept of @mountpoint decorator is a viable option. I will see if i can come up with something on this weekend. Again appreciate your response and your work. You can close this issue. Thanks!