Skip to content

Routers #83

Open
Open
@ZeroIntensity

Description

@ZeroIntensity

Feature description

To support or help people migrate from other libraries, view.py should introduce routers. These should be quite easy to implement, and the loader should take care of most of it.

Feature example API

A very basic implementation would be:

from view import new_app, Router

app = new_app()
router = Router()

@router.get("/")
async def index():
    return "hello, view.py"


app.load([router])
app.run()

I think we could go further though, and have some magic involved:

from view import new_app, new_router

app = new_app()
router = new_router(prefix="/hello")  # call get_app() internally and assign a router to the app instance

@router.get("/")
async def index():
    return "hello, view.py"

# automatically assign routes to app
app.run()

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiThis has to do with the Python API (view)featureNew featuregood first issueAn issue that isn't necessarily easy to implement, but not required to be an expert in view.py

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions