-
Notifications
You must be signed in to change notification settings - Fork 4
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
docs: add example of Modify (redefine) response only to particular endpoint
#37
base: main
Are you sure you want to change the base?
Conversation
from starlette.requests import Request | ||
from fastapi_proxy_lib.core.http import ReverseHttpProxy | ||
|
||
app = FastAPI() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps adding lifespan
would be better?
app = FastAPI(lifespan=close_proxy_event)
from fastapi_proxy_lib.core.http import ReverseHttpProxy | ||
|
||
app = FastAPI() | ||
proxy = ReverseHttpProxy(base_url="https://httpbin.org/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should use http
here?
Ref: https://wsh032.github.io/fastapi-proxy-lib/Usage/Security/#httpws-vs-httpswss
|
||
@app.get("/{path:path}") | ||
async def _(request: Request, path: str = ""): | ||
if path == "ip" and request.method == "GET": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add @app.post("/{path:path}")
here? Because I see below there's a check for request.method == "GET"
.
Hi @pavelsr ! Well done! 🎉 Every pull request targeting the documentation is appreciated! Thank you for your contribution! I have left some reviews, could you take a look at them? The CI pipeline encountered some errors, but don't worry, I'll fix it. |
Modify (redefine) response only to particular endpoint
The CI pipeline encountered some issues from the upstream (codecov/feedback#358). #28 Upgrading to |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #37 +/- ##
=======================================
Coverage 96.74% 96.74%
=======================================
Files 9 9
Lines 461 461
Branches 67 67
=======================================
Hits 446 446
Misses 9 9
Partials 6 6 ☔ View full report in Codecov by Sentry. |
Summary
First off all, Sean @WSH032, thanks for this library
I added one more example to Advanced usage
My example can be useful for API A/B testing or hiding particular methods of upstream
Close: #36
Checklist
CONTRIBUTING.md
.