Hi All 👋

I’m excited to share that the latest version of Robyn now includes dependency injections but with a unique syntax.

For those who might not be familiar, Robyn is a fast, asynchronous Python backend web framework that operates with a Rust runtime, combining the best of both worlds for efficient and robust web development.

Here’s a sample example to illustrate the new feature:

from robyn import Robyn, ALLOW\_CORS

app = Robyn(__file__)

GLOBAL_DEPENDENCY = "GLOBAL DEPENDENCY"
ROUTER_DEPENDENCY = "ROUTER DEPENDENCY"

app.inject(ROUTER_DEPENDENCY=ROUTER_DEPENDENCY)
app.inject_global(GLOBAL_DEPENDENCY=GLOBAL_DEPENDENCY)

@app.get("/sync/global_di")
def sync_global_di(request, router_dependencies, global_dependencies):
   return global_dependencies["GLOBAL_DEPENDENCY"]  

It was one of the most requested features, and I’m curious to hear what the community thinks about this new approach. Any feedback or thoughts are greatly appreciated!

And as usual, the project can be found at: https://github.com/sparckles/Robyn

  • fediverser_bot@fediverser.communick.dev
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    This post is an automated archive from a submission made on /r/python, powered by Fediverser software running on fediverser.communick.dev. Responses to this submission will not be seen by the original author until they claim ownership of their fediverser.communick.dev account. Please consider reaching out to them let them know about this post and help them migrate to Lemmy.

    Lemmy users: you are still very much encouraged to participate in the discussion. There are still many other subscribers on !python@fediverser.communick.dev that can benefit from your contribution and join in the conversation.

    Reddit users: you can also join the fediverse right away by getting by visiting https://fediverser-portal.communick.dev/. If you are looking for a Reddit alternative made for and by an independent community, check out Fediverser.