Skip to content

Instantly share code, notes, and snippets.

@Goldziher
Last active January 2, 2022 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Goldziher/e293c148fe2f0bd89b7ad090f98f8b83 to your computer and use it in GitHub Desktop.
Save Goldziher/e293c148fe2f0bd89b7ad090f98f8b83 to your computer and use it in GitHub Desktop.
Route Handlers Example
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