Classic HTTP Api
Этот пакет содержит вариант HTTP API, совместимый с принципами Ioc и DI. Является оберткой над фреймворком Falcon, позволяющей описывать входные и выходные параметр входных точек с помощью [msgspec][https://jcristharif.com/msgspec/index.html], и предстоявлящей интеграцию с OpenAPI и Swagger.
Пример:
from falcon import Request, Response
from classic.components import component
from classic.http_api import App, specification
import msgspec
# Описывает параметры запроса для GET /api/some_obj
class SomeObjFilter(msgspec.Struct):
number: int
# Описывает структуру ответа
class SomeObj(msgspec.Struct):
some_attr: int
# Описывает структуру запроса для POST /api/some_obj
class CreateSomeObjRequest(msgspec.Struct):
some_attr: int
@component
class SomeObjResource:
@specification(query=SomeObjFilter, response=SomeObj)
def on_get(self, request: Request, response: Response):
# Представим себе, что объекты берутся из БД
response.media = [
SomeObj(number)
for number in range(
# Объект запроса содержится в контексте под именем media.
request.context.media.number,
)
]
@specification(media=CreateSomeObjRequest, response=SomeObj)
def on_post(self, request: Request, response: Response):
# Представим себе, что объект был сохранен в БД;)
response.media = SomeObj(
**msgspec.structs.asdict(request.context.media)
)
# Композит
if __name__ == '__main__':
from wsgiref.simple_server import make_server
app = App(openapi=True)
app.add_route('/api/some_obj', SomeObjResource())
#
with make_server('', 8000, app) as httpd:
httpd.serve_forever()
Metadata
Release files for classic-http-api 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| classic-http-api-2.1.0.tar.gz | 7.7 kB | Without provenance | Details |
Release files / classic-http-api-2.1.0.tar.gz
| Download URL | classic-http-api-2.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dc5a18a241dd4906e3deb23a5c6568d3448eaaac60ca2c8d2c9e5099bce4c83
|
|
BLAKE2b-256 checksum How to use checksums |
07d30f0baefd6bf4113324de1c6bc1cc922c2df9119514b8145248e060199178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Security for classic-http-api 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.