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

contrib/dimfeld/httptreemux.v5: fix route and name for 30X redirects #2664

Closed

Commits on Apr 25, 2024

  1. contrib/dimfeld/httptreemux.v5: fix route and name for 30X redirects

    The httptreemux router has a redirect behaviour that is invoked when
    a request URL and matched route only differs in a trailing slash. The
    default behaviour is to respond with a 301 (moved permanently) to
    redirect the client to the exact path of the matched handler. We
    previously patched one of the two scenarios where this occurs in DataDog#2332.
    The changes in this commit addresses the other scenario for the 301
    redirect, but also the 307 and 308 redirect options. Several tests
    were included to cover the various scenarios.
    
    We also standardize the resource name in the event that there is a
    trailing slash missmatch between request URL and matched handler. We
    always truncate the trailing slash in the resource name.
    
    Fixes DataDog#2663
    devillecodes committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    41f1176 View commit details
    Browse the repository at this point in the history
  2. contrib/dimfeld/httptreemux.v5: simplified function comments

    Simplied the unnecessarily verbose function comments of
    isSupportedRedirectStatus and routerRedirectEnabled.
    devillecodes committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    bc25daf View commit details
    Browse the repository at this point in the history
  3. contrib/dimfeld/httptreemux.v5: removed redundant redirect tests

    The new tests added to assert the redirect behaviour for
    the four redirect modes supported by the router had
    redundant test cases.
    
    These test cases were reduced down to three scenarios per
    redirect mode:
    1. path not found
    2. path with parameterized URL excluding a trailing slash
    3. path with parameterized URL inclduing a trailing slash
    devillecodes committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    aeb6214 View commit details
    Browse the repository at this point in the history
  4. contrib/dimfeld/httptreemux.v5: do not trim slash from path

    When handling the supported redirect modes of the router
    we were incorrectly trimming trailing slashes from the
    route path matched by the router. The previous behaviour
    is restored where we return the exact path matched by
    the router.
    devillecodes committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    4d3f72e View commit details
    Browse the repository at this point in the history