Skip to content

WIP - Version 6 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

WIP - Version 6 #52

wants to merge 1 commit into from

Conversation

vincentsarago
Copy link
Owner

This PR is a first sketch for next lambda-proxy version (6)

Changes:

  • New way to create and handle response
  • New way to hander exception
  • FastAPI/Starlette style API
  • JSON is the new default response model

Version 5 (Master)

@app.get("/ping", cors=True)		
def health():		
    return ("OK", "text/plain", "I'm healthy")

Version 6 (This PR)

from lambda_proxy.responses import PlainTextResponse

@app.get("/ping", cors=True, response_class=PlainTextResponse)		
def health():		
    return "I'm way more healthy"
Bonus - Custom headers

inspired by https://fastapi.tiangolo.com/advanced/response-headers/#use-a-response-parameter

from lambda_proxy.responses import Response, PlainTextResponse

@app.get("/ping", cors=True, response_class=PlainTextResponse)		
def health(resp: Response):
    resp.headers["X-Custom"] = "This is cool"
    return "I'm way more healthy"

cc @kylebarron

@vincentsarago
Copy link
Owner Author

To Do

  • update tests
  • update docs
  • update demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant