generated from tbobm/gha-dynamic-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from tbobm/feat/add-http-api-dump
Add HTTP API dump
- Loading branch information
Showing
5 changed files
with
371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM python:3.12-slim as release | ||
|
||
WORKDIR /app | ||
|
||
EXPOSE 8000 | ||
RUN pip install poetry | ||
# NOTE: could implement healthcheck | ||
|
||
# install dependencies | ||
COPY . . | ||
|
||
RUN poetry install | ||
|
||
ENTRYPOINT [ "poetry", "run", "uvicorn", "dump.main:app", "--host", "0.0.0.0" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Union | ||
|
||
from fastapi import FastAPI, Request | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.api_route("/{full_path:path}", methods=["HEAD", "GET", "POST", "DELETE", "PUT"]) | ||
async def read_root(request: Request, full_path: str): | ||
response = { | ||
"path": full_path, | ||
"method": request.method, | ||
} | ||
response['headers'] = request.headers | ||
_json = None | ||
try: | ||
_json = await request.json() | ||
if _json is not None: | ||
response['json'] = _json | ||
except Exception: | ||
# no json payload | ||
pass | ||
_form = await request.form() | ||
if _form is not None: | ||
response['form'] = _form | ||
return response |
Oops, something went wrong.