2022-05-09 23:08:49 +00:00
|
|
|
from typing import Awaitable, Callable, Optional
|
2022-04-14 12:33:53 +00:00
|
|
|
from app.classes.web.base_handler import BaseHandler
|
|
|
|
|
|
|
|
|
|
|
|
class BaseApiHandler(BaseHandler):
|
2022-05-09 23:08:49 +00:00
|
|
|
# {{{ Disable XSRF protection on API routes
|
2022-05-05 00:32:09 +00:00
|
|
|
def check_xsrf_cookie(self) -> None:
|
2022-04-14 12:33:53 +00:00
|
|
|
pass
|
2022-05-09 23:08:49 +00:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# {{{ 405 Method Not Allowed as JSON
|
|
|
|
def _unimplemented_method(self, *_args: str, **_kwargs: str) -> None:
|
|
|
|
self.finish_json(405, {"status": "error", "error": "METHOD_NOT_ALLOWED"})
|
|
|
|
|
|
|
|
head = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
get = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
post = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
delete = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
patch = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
put = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
options = _unimplemented_method # type: Callable[..., Optional[Awaitable[None]]]
|
|
|
|
# }}}
|