Last active
January 2, 2022 08:57
-
-
Save Goldziher/e293c148fe2f0bd89b7ad090f98f8b83 to your computer and use it in GitHub Desktop.
Route Handlers Example
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 starlite import Partial, delete, get, patch, post, put | |
from my_app.models import Resource | |
@get(path="/resources") | |
def list_resources() -> List[Resource]: | |
... | |
@post(path="/resources") | |
def create_resource(data: Resource) -> Resource: | |
... | |
@get(path="/resources/{pk:int}") | |
def retrieve_resource(pk: int) -> Resource: | |
... | |
@put(path="/resources/{pk:int}") | |
def update_resource(data: Resource, pk: int) -> Resource: | |
... | |
@patch(path="/resources/{pk:int}") | |
def partially_update_resource(data: Partial[Resource], pk: int) -> Resource: | |
... | |
@delete(path="/resources/{pk:int}") | |
def delete_resource(pk: int) -> None: | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment