-
Notifications
You must be signed in to change notification settings - Fork 291
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
Mobile app proxy gateway #3449
Mobile app proxy gateway #3449
Conversation
if settings.MOBILE_APP_GATEWAY_ENABLED: | ||
urlpatterns += [ | ||
re_path( | ||
r"^gateway/(?P<downstream_backend>\w*)/(?P<downstream_path>.*)$", |
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.
basically this would proxy the following request:
GET /mobile_app/v1/gateway/incident/test/123/someotherthing/456
into:
downstream_backend = "incident"
downstream_path = "test/123/someotherthing/456"
@classmethod | ||
def _get_downstream_url(cls, organization: "Organization", downstream_backend: str, downstream_path: str) -> str: | ||
downstream_url = { | ||
cls.SupportedDownstreamBackends.INCIDENT: organization.grafana_incident_backend_url, |
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.
in the future, if we want to add a new proxied backend, we simply need to add a mapping here from the URLConf's downstream_backend
to the downstream service's root URL
""" | ||
See the default `APIView.dispatch` for more info. Basically this just routes all requests for | ||
ALL HTTP verbs to the `MobileAppGatewayView._proxy_request` method. | ||
""" | ||
for method in APIView.http_method_names: | ||
setattr(MobileAppGatewayView, method.lower(), MobileAppGatewayView._proxy_request) |
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.
"hackier" way to support proxying all HTTP verbs
What this PR does
Closes https://github.com/grafana/oncall-private/issues/2324
Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)