Last active
January 3, 2022 13:03
-
-
Save Goldziher/982726896e60b19b312b7ec04f74acb1 to your computer and use it in GitHub Desktop.
Example Starlite Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
from pydantic import UUID4 | |
from starlite import Controller, Partial, get, post, put, patch, delete | |
from my_app.models import User | |
class UserController(Controller): | |
path = "/users" | |
@post() | |
async def create_user(self, data: User) -> User: | |
... | |
@get() | |
async def list_users(self) -> List[User]: | |
... | |
@patch(path="/{user_id:uuid}") | |
async def partially_update_user(self, user_id: UUID4, data: Partial[User]) -> User: | |
... | |
@put(path="/{user_id:uuid}") | |
async def update_user(self, user_id: UUID4, data: User) -> User: | |
... | |
@get(path="/{user_id:uuid}") | |
async def get_user(self, user_id: UUID4) -> User: | |
... | |
@delete(path="/{user_id:uuid}") | |
async def delete_user(self, user_id: UUID4) -> User: | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment