Nebula - 3.1.1
Nebula 3.1.1 - Release Notes
What’s New
request object is no longer always injected automatically into route handlers.
Request is now only injected when one of the following conditions is met:
a) The parameter is named request
b) The parameter is type-annotated with Request (or a compatible class)
If neither condition is met, the request can still be accessed via nebula.get_request().
Examples
❌ No request injection
from nebula.response import HTMLResponse
@app.get("/", return_class=HTMLResponse)
async def root() -> HTMLResponse:
return "<h1>Welcome to Nebula!</h1>"❌ No request injection (other parameters)
@app.get("/{something}", return_class=HTMLResponse)
async def something(something) -> HTMLResponse:
return f"<h1>Welcome to {something}!</h1>"✅ Request injected via type annotation
from nebula.request import Request
from nebula.response import HTMLResponse
@app.get("/route", return_class=HTMLResponse)
async def route(request: Request) -> HTMLResponse:
return f"<h1>You're currently on: http://{app.host}:{app.port}{request.path}</h1>"✅ Request injected regardless of parameter name
@app.get("/route2", return_class=HTMLResponse)
async def route2(req: Request) -> HTMLResponse:
return f"<h1>You're currently on: http://{app.host}:{app.port}{req.path}</h1>"✅ Access request via get_request()
from nebula import get_request
from nebula.response import HTMLResponse
@app.get("/route3", return_class=HTMLResponse)
async def route3() -> HTMLResponse:
return f"<h1>You're currently on: http://{app.host}:{app.port}{get_request().path}</h1>"Migration Guide
If your existing routes relied on implicit request injection, update them by:
- Adding request:
Requestto your route handler, or - Using
nebula.get_request()inside your function
Notes
- The parameter name does not matter if it is annotated with Request.
- This change makes request handling more explicit and predictable.