Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Regardless whether versioning can be avoided by doing backwards compatible changes (which might not always possible when you are bound by some corporate guidelines or your API clients are implemented in a buggy way and would break even if they should not) the abstracted requirement is an interesting one: </p> <p><strong>How can I do a custom request mapping that does arbitrary evaluations of header values from the request without doing the evaluation in the method body?</strong></p> <p>As described in <a href="https://stackoverflow.com/a/10336769/2615437">this SO answer</a> you actually can have the same <code>@RequestMapping</code> and use a different annotation to differentiate during the actual routing that happens during runtime. To do so, you will have to:</p> <ol> <li>Create a new annotation <code>VersionRange</code>.</li> <li>Implement a <code>RequestCondition&lt;VersionRange&gt;</code>. Since you will have something like a best-match algorithm you will have to check whether methods annotated with other <code>VersionRange</code> values provide a better match for the current request.</li> <li>Implement a <code>VersionRangeRequestMappingHandlerMapping</code> based on the annotation and request condition (as described in the post<a href="https://stackoverflow.com/a/10336769/2615437"> How to implement @RequestMapping custom properties </a>).</li> <li>Configure spring to evaluate your <code>VersionRangeRequestMappingHandlerMapping</code> before using the default <code>RequestMappingHandlerMapping</code> (e.g. by setting its order to 0).</li> </ol> <p>This wouldn't require any hacky replacements of Spring components but uses the Spring configuration and extension mechanisms so it should work even if you update your Spring version (as long as the new version supports these mechanisms).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload