-
-
Notifications
You must be signed in to change notification settings - Fork 1
Fallback to the old API for undefined routes. #14
Conversation
This adds a new endpoint handler using the `path` converter in order to match requests directed to any subtree. As long as this endpoint is the last to be included in the router, all requests not matching defined routes under the `/api` endpoint will be forwarded to the old API. Two new settings are added for this. One is the endpoint of the old API to forward to, which may change in the future due to the pending subdomain removal pull request. The other is the API token to use for the new API authenticating with the old API: Whilst everything else sent by the client is forwarded to the old API, the authorization schemes between the new and old API differ. The entire point behind this functionality is to allow us to incrementally port over endpoints to the new API, whilst reconfiguring clients to use the new API completely. Closes #8.
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.
Interesting implementation of proxying request the old api. Two small comments and rest looks good. I am not really sure about the tests if there is a better way to do the mocking.
Could we possibly add the python-discord/site GHCR package to |
I also thought about that, but decided against it, due to the docker initialization steps required to get the site up and running. I don't really want to duplicate |
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.
Looks good! Thanks
status_code=forward_response.status_code, | ||
) | ||
|
||
except Exception as err: |
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.
Everything looks good to me. Although, it might be possible that here, httpx.RequestError
is better,
as FastAPI will raise the errors internally for the rest of the code.
(I'm talking about
body = await request.body()
That will raise RequestValidationError
internally, in case something goes wrong.)
Closing this per us sunsetting this project. |
This adds a new endpoint handler using the
path
converter in order to matchrequests directed to any subtree. As long as this endpoint is the last to be
included in the router, all requests not matching defined routes under the
/api
endpoint will be forwarded to the old API.Two new settings are added for this. One is the endpoint of the old API to
forward to, which may change in the future due to the pending subdomain removal
pull request. The other is the API token to use for the new API authenticating
with the old API: Whilst everything else sent by the client is forwarded to the
old API, the authorization schemes between the new and old API differ.
The entire point behind this functionality is to allow us to incrementally port
over endpoints to the new API, whilst reconfiguring clients to use the new API
completely.
Closes #8.