Support new API Gateway HTTP APIs
See original GitHub issueHi there, I’m getting the following error when my app executes in API Gateway (paths shortened for brevity):
Traceback (most recent call last):
File "/virtualenv/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 134, in handle
self.handle_request(listener, req, client, addr)
File "/virtualenv/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/virtualenv/lib/python3.8/site-packages/mangum/adapter.py", line 61, in __call__
raise exc
File "/virtualenv/lib/python3.8/site-packages/mangum/adapter.py", line 59, in __call__
response = self.handler(event, context)
File "/virtualenv/lib/python3.8/site-packages/mangum/adapter.py", line 76, in handler
response = self.handle_ws(event, context)
File /virtualenv/lib/python3.8/site-packages/mangum/adapter.py", line 130, in handle_ws
request_context = event["requestContext"]
KeyError: 'requestContext'
Here is my FastApi app code:
from fastapi import FastAPI
from app.api import router
def get_application(config) -> FastAPI:
application = FastAPI(
title=config.PROJECT_NAME, debug=config.DEBUG, version=config.VERSION
)
application.include_router(router, prefix=config.API_PREFIX)
return application
And here is the Mangum adapter:
from mangum import Mangum
from .app import get_application
from .core import config
handler = Mangum(app=get_application(config), enable_lifespan=False)
Also tried running locally with gunicorn
, same error. If I run the app normally with uvicorn
it works fine.
I’m using the latest version of FastAPI (0.54.1) and Python 3.8 on a Manjaro Linux machine.
So, according to the examples I’ve read, that looks like pretty standard stuff; I looked online but couldn’t find anything (and the issues posted here seems like they are for old versions), am I missing something?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Working with HTTP APIs - Amazon API Gateway
REST APIs and HTTP APIs are both RESTful API products. REST APIs support more features than HTTP APIs, while HTTP APIs are designed...
Read more >The Official Guide to AWS HTTP APIs - Serverless Framework
AWS HTTP APIs are the latest iteration of tooling for creating APIs with the Amazon API Gateway. They offer a variety of significant...
Read more >API Gateway REST vs. HTTP API: What Are The Differences?
AWS API Gateway is a great technology for managing and securing access to your backend REST APIs. However, AWS currently supports two very ......
Read more >Amazon API Gateway for the .NET Developer - How To Build ...
Once you click 'Review and Create', a new API Gateway Endpoint is ... Supported Integration types when building HTTP APIs on Amazon API ......
Read more >AWS API Gateway: HTTP vs REST
AWS API Gateway provides two different service, REST and HTTP and it can ... introduced a new flavor of the API Gateway, called...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Released in 0.8.0.
I’ve merged the PR for this into
master
, but there are a few things I want to do before the next release (probably this weekend). I’ll leave this open until then.