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 decorator router #59

Closed
3 tasks done
cirospaciari opened this issue Jan 3, 2023 · 1 comment
Closed
3 tasks done

Add decorator router #59

cirospaciari opened this issue Jan 3, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@cirospaciari
Copy link
Owner

cirospaciari commented Jan 3, 2023

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
@cirospaciari cirospaciari added enhancement New feature or request documentation Improvements or additions to documentation labels Jan 3, 2023
@cirospaciari cirospaciari self-assigned this Jan 3, 2023
@cirospaciari
Copy link
Owner Author

Will be released on v0.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant