justapi — /docs

Using APIRouter

Split your application into multiple files:

# routers/users.py
from justapi import APIRouter

router = APIRouter(prefix="/users", tags=["users"])

@router.get("/")
def list_users():
    return []

@router.get("/{user_id}")
def get_user(user_id: int):
    return {"user_id": user_id}
# main.py
from justapi import JustAPIApp
from routers.users import router as users_router

app = JustAPIApp()
app.include_router(users_router)

Prefix and Tags

app.include_router(users_router, prefix="/api/v1", tags=["users"])

All routes in users_router now start with /api/v1/users/.

Mounting Sub-Applications

Mount an APIRouter at a path prefix:

from justapi import APIRouter, JustAPIApp

app = JustAPIApp()
users_router = APIRouter(prefix="/users")

@users_router.get("/{user_id}")
def get_user(user_id: int):
    return {"user_id": user_id}

app.mount("/api/v2", users_router)

mount() accepts either an APIRouter (or any object exposing .routes) or a static directory path:

# Mount a static directory
app.mount("/static", "static", name="static")

Note: JustAPI does not mount third-party ASGI/Starlette applications — the runtime is a native Rust pipeline with its own routing and middleware. For sub-app structure use APIRouter + mount() (or include_router). Run existing Starlette/FastAPI apps unchanged by placing JustAPI behind a proxy that routes by path (see Behind a Proxy).

See Also

JustAPI v2.0.9 — Open Source MIT License · Built with WebTUI · GitHub

NORMAL master justapi/docs
utf-8 Top 1:1