Skip to content

Add decorator router #59

@cirospaciari

Description

@cirospaciari

Is really good for DX just use something like:

from socketify import App

app = App()
router = app.router()

@router.get("/")
def home(res, req):
   res.end("Hello World!")

api = app.router(prefix="/api")

@api.get("/")
def home(res, req):
   res.end("Hello API!")

private = app.router(prefix="/api", token_middleware)

@private.get("/users")
def get_users(res, req, data=None):
   res.end("Hello private API!")

app.listen(
    3000,
    lambda config: print("Listening on port http://localhost:%d now\n" % config.port),
)
app.run()
  • Create app.router() inspired in Middleware router but using decorators
  • Add Documentation
  • Optimize for sync middleware with res.run_async

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions