Provides wrapper around Falcon web framework, adding class-app-layer support
Project description
Classic HTTP Api
This package provides base for http APIs, based Falcon framework.
Part of project "Classic".
Usage:
from classic.http_api import App
class Reports:
def on_get_for_day(self, request, response):
response.media = {'day': 'report'}
def on_get_for_month(self, request, response):
response.media = {'day': 'period'}
app = App()
# Will generate URLs:
# /api/reports/for_day
# /api/reports/for_month
app.register(Reports())
# If we need to customize url:
app.register(Reports(), url='/order_reports')
# Urls will be:
# /api/order_reports/for_day
# /api/order_reports/for_month
# We may register methods only:
app.add_method('/reports/daily', Reports(), suffix='for_day')
# Url will be /api/reports/daily
# prefix may be customized in App class:
app = App(prefix='/api/custom')
# Now, URL will be /api/custom/reports/daily
app.add_method('/reports/daily', Reports(), suffix='for_day')
Also, App class can transform pydantic.ValidationError, AppError and ErrorsList from classic.app to formats:
ValidationError:
[
{
"type": "namespace.error_code",
"msg": "Verbose message",
"loc": ["path", "to", "error"]
}
]
AppError:
[
{
"type": "namespace.error_code",
"msg": "Verbose message",
"ctx": {"any_key": "any_useful_info"}
}
]
Also, this response statuses in this cases will be 400.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
classic-http-api-0.0.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for classic_http_api-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7f9d64846562781eaadb6d551957052249fe84cbfa5f383c53a9a056980825f |
|
MD5 | 89ec677eb16d3a87dc519cf9046a27dd |
|
BLAKE2b-256 | b5fa260e9c7658edce627b54dc679ad998c6d67028054806e23982c62f7cd645 |