Skip to content

Nebula - 3.1.4

Choose a tag to compare

@VxidDev VxidDev released this 31 Mar 16:37

Nebula 3.1.4 - Release Notes

What’s New

⚠️ Behavior change: Automatic response wrapping has been updated.

Added RouteGroup, enabling cleaner and more organized route definitions, and laying the foundation for future middleware support and route isolation.


RouteGroup

RouteGroup is a utility that helps simplify and organize route definitions. It also introduces the groundwork for future middleware isolation between the main Nebula application and grouped routes.

Examples

api: RouteGroup = app.group("/api")

@api.get("/weather")
async def weather():
    return {"temperature": 27}

⚠️ Middleware isolation is not yet implemented. For now, RouteGroup acts as a structural wrapper.


New Behavior

Previously, you could explicitly pass a response class:

@app.get("/", return_class=HTMLResponse)
async def root() -> None:
     return "<h1>Welcome to Nebula!</h1>"

Now, Nebula also inspects the route’s return type annotation. If a valid class that inherits from Response is provided, and the user has not explicitly passed return_class, the return type annotation will be used automatically.


Examples

# returns HTMLResponse

@app.get("/", return_class=HTMLResponse)
async def root() -> None:
    return "<h1>Welcome to Nebula!</h1>"

# also returns HTMLResponse
@app.get("/a")
async def something() -> HTMLResponse:
    return "<h1>Welcome to Nebula!</h1>"

# returns PlainTextResponse
@app.get("/b", return_class=PlainTextResponse)
async def something_again() -> HTMLResponse:
    return "<h1>Welcome to Nebula!</h1>"