Skip to content

v0.32.0 - Implement SubRouters

Compare
Choose a tag to compare
@sansyrox sansyrox released this 03 Jun 23:16
· 183 commits to main since this release

We're proud to announce the addition of SubRouters to Robyn. This feature allows developers to create subrouters, providing a convenient way to group routes together.

The functionality of SubRouters extends to both normal routes and web sockets, acting as a smaller-scale replica of the main router. SubRouters can be utilized in exactly the same way as the main router, with the minor prerequisite of adding the SubRouter to the main router.

We hope you enjoy the increased flexibility this feature brings to your routing capabilities in Robyn! As always, we look forward to your feedback.

What's Changed

New Contributors

Sample Usage

SubRouters

You can create subrouters in Robyn. This is useful when you want to group routes together.

Subrouters can be used for both normal routes and web sockets. They are basically a mini version of the main router and can be used in the same way.

The only caveat is that you need to add the subrouter to the main router.

from robyn import Robyn, SubRouter

app = Robyn(__file__)

sub_router = SubRouter("/sub_router")

@sub_router.get("/hello")
def hello():
    return "Hello, world"

web_socket = SubRouter("/web_socket")

@web_socket.message()
async def hello():
    return "Hello, world"

app.add_sub_router(sub_router)

Full Changelog: v0.31.0...v0.32.0