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

PB-796: handle paths without trailing slash without redirection. #440

Merged
merged 3 commits into from
Aug 13, 2024

Commits on Aug 13, 2024

  1. PB-796: handle paths without trailing slash without redirection.

    API Gateway v1 strips trailing slashes from the request paths.
    We have a few endpoints that use trailing slashes. Specifically:
    
    - /api/stac/v1/
    - /api/stac/v0.9/
    - /api/stac/admin/*
    
    Django's CommonMiddleware already has a feature to redirect URLs without
    trailing slash to their "slashed" equivalent when they exist. When combined
    with API Gateway v1 this causes a redirection loop.
    
    This change introduces CommonMiddlewareWithInternalRedirect which handles the
    redirection internally to serve the query like if it had hit the "slashed" page
    directly.
    
    It also updates the test to verify both endpoints work correctly.
    
    Based on discussion in https://ltwiki.adr.admin.ch:8443/display/~adrien.kunysz@swisstopo.ch/STAC+API+trailing+slash+inconsistency
    adk-swisstopo committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    d2c5553 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    253dee2 View commit details
    Browse the repository at this point in the history
  3. Mark f-string as such.

    adk-swisstopo committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    4eda290 View commit details
    Browse the repository at this point in the history