Skip to content
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

Merged
merged 13 commits into from
Dec 5, 2023
Merged

Mobile app proxy gateway #3449

merged 13 commits into from
Dec 5, 2023

Conversation

joeyorlando
Copy link
Contributor

@joeyorlando joeyorlando commented Nov 28, 2023

What this PR does

Closes https://github.com/grafana/oncall-private/issues/2324

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

@joeyorlando joeyorlando changed the title WIP - mobile app proxy gateway Mobile app proxy gateway Nov 28, 2023
@joeyorlando joeyorlando marked this pull request as ready for review November 28, 2023 21:41
@joeyorlando joeyorlando requested a review from a team November 28, 2023 21:41
@joeyorlando joeyorlando added the pr:no public docs Added to a PR that does not require public documentation updates label Nov 28, 2023
if settings.MOBILE_APP_GATEWAY_ENABLED:
urlpatterns += [
re_path(
r"^gateway/(?P<downstream_backend>\w*)/(?P<downstream_path>.*)$",
Copy link
Contributor Author

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,
Copy link
Contributor Author

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

Comment on lines +190 to +195
"""
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)
Copy link
Contributor Author

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

@joeyorlando joeyorlando added this pull request to the merge queue Dec 5, 2023
Merged via the queue into dev with commit 382b18b Dec 5, 2023
20 checks passed
@joeyorlando joeyorlando deleted the jorlando/mobile-app-proxy branch December 5, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants