sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.

Home Page:https://sanic.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please add more examples of Sanic usage without decorators to documentation

nicolaipre opened this issue · comments

commented

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

No, none that I could find.

Describe the solution you'd like

It would be great with some more/extended documentation on how to use Sanic without using decorators, i.e: https://sanic.dev/en/guide/basics/routing.html#adding-a-route

Almost every example of routing (apart from the single example above), middleware, OpenAPI (sanic-ext), etc.. there are only examples using decorators, and no examples without using decorators.

I really like Sanic as a framework for its stability and rapid speed, but I simply cannot stand being forced to use decorators and try to avoid them by any means necessary as I don't want them in my code.

Maybe the documentation could provide two examples of code (with and without decorators) that gave users the choice of whether or not they want to use decorators?

Additional context

Improves user experience for people wanting to use Sanic as their base framework.

Decorators are the way Sanic is intended to be used. https://sanic.dev/en/guide/advanced/class-based-views.html#class-based-views are an alternative that doesn't so directly depend on decorators.

Also note that you can replace any decorator by separate function call, like

async def handler(request):
    ...

app.get("/")(handler)