Skip to content

Commit

Permalink
Use mangum in fastapi and change method to any
Browse files Browse the repository at this point in the history
  • Loading branch information
fulder committed Oct 28, 2021
1 parent 2f7da83 commit f7198ae
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ generate-hashes:
pip-compile --generate-hashes src/layers/databases/requirements.in --output-file src/layers/databases/requirements.txt --allow-unsafe
pip-compile --generate-hashes src/layers/utils/requirements.in --output-file src/layers/utils/requirements.txt --allow-unsafe
pip-compile --generate-hashes deploy/requirements.in --output-file deploy/requirements.txt --allow-unsafe
pip-compile --generate-hashes src/lambdas/watch_histories/requirements.in --output-file src/lambdas/watch_histories/requirements.txt
pip-compile --generate-hashes src/lambdas/api/watch_histories/requirements.in --output-file src/lambdas/api/watch_histories/requirements.txt
2 changes: 1 addition & 1 deletion deploy/lib/watch_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def _create_gateway(self):

routes = {
"watch_histories": {
"method": ["GET"],
"method": ["ANY"],
"route": "/{proxy+}",
"target_lambda": self.lambdas["api-watch_histories"]
},
Expand Down
8 changes: 6 additions & 2 deletions src/lambdas/api/watch_histories/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from fastapi import FastAPI
from mangum import Mangum

app = FastAPI()


@app.get("/watch-histories/item")
async def root():
return {"message": "Hello World"}
def item(api_name: str, api_id: str):
return {"message": f"Got {api_name}_{api_id}"}


handler = Mangum(app)
3 changes: 2 additions & 1 deletion src/lambdas/api/watch_histories/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fastapi==0.70.0
fastapi==0.70.0
mangum==0.12.3
12 changes: 9 additions & 3 deletions src/lambdas/api/watch_histories/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --generate-hashes --output-file=src/lambdas/watch_histories/requirements.txt src/lambdas/watch_histories/requirements.in
# pip-compile --generate-hashes --output-file=src/lambdas/api/watch_histories/requirements.txt src/lambdas/api/watch_histories/requirements.in
#
anyio==3.3.4 \
--hash=sha256:4fd09a25ab7fa01d34512b7249e366cd10358cdafc95022c7ff8c8f8a5026d66 \
Expand All @@ -11,11 +11,15 @@ anyio==3.3.4 \
fastapi==0.70.0 \
--hash=sha256:66da43cfe5185ea1df99552acffd201f1832c6b364e0f4136c0a99f933466ced \
--hash=sha256:a36d5f2fad931aa3575c07a3472c784e81f3e664e3bb5c8b9c88d0ec1104f59c
# via -r src/lambdas/watch_histories/requirements.in
# via -r src/lambdas/api/watch_histories/requirements.in
idna==3.3 \
--hash=sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff \
--hash=sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d
# via anyio
mangum==0.12.3 \
--hash=sha256:128a8c1aa2eef13fc94ac5344210df8bd71dfba584b658bec9473e784bd86301 \
--hash=sha256:a45cc1c57736e7044318e65216eea83a397cb709e39fe6810a46faf0e15d2664
# via -r src/lambdas/api/watch_histories/requirements.in
pydantic==1.8.2 \
--hash=sha256:021ea0e4133e8c824775a0cfe098677acf6fa5a3cbf9206a376eed3fc09302cd \
--hash=sha256:05ddfd37c1720c392f4e0d43c484217b7521558302e7069ce8d318438d297739 \
Expand Down Expand Up @@ -52,4 +56,6 @@ typing-extensions==3.10.0.2 \
--hash=sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e \
--hash=sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7 \
--hash=sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34
# via pydantic
# via
# mangum
# pydantic

0 comments on commit f7198ae

Please sign in to comment.