Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ton-http-api/pyTON/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ def main_config(binder):

settings = inject.instance(Settings)

pkg_version = '2.0.0'

app = FastAPI(
title="TON HTTP API",
description=description,
version='2.0.0',
version=pkg_version,
docs_url='/',
responses={
422: {'description': 'Validation Error'},
Expand Down Expand Up @@ -138,6 +140,14 @@ async def startup():
async def shutdown_event():
await tonlib.shutdown()


@app.middleware("http")
async def add_process_time_header(request: Request, call_next):
response = await call_next(request)
response.headers["X-API-Version"] = pkg_version
return response


# Exception handlers
@app.exception_handler(StarletteHTTPException)
async def http_exception_handler(request, exc):
Expand Down
2 changes: 1 addition & 1 deletion ton-http-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ requests==2.28.0
ring==0.10.1
uvicorn==0.17.6
gunicorn==20.1.0
pytonlib==0.0.67
pytonlib==0.0.68
inject==4.3.1
2 changes: 1 addition & 1 deletion ton-http-api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'ring==0.10.1',
'uvicorn==0.17.6',
'gunicorn==20.1.0',
'pytonlib==0.0.67',
'pytonlib==0.0.68',
'inject==4.3.1'
],
package_data={},
Expand Down
Loading