Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-16336

Ability to provide an external base path for controllers

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0.2
    • Fix Version/s: 5.1 RC1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I'm certain wrote, or commented on a similar bug that I currently can't find. I'd like the ability to do this with classes annotated with @Controller, and perhaps separately for @RestController.

      @Configuration
      class RestConfig extends RepositoryRestConfigurerAdapter {
      
          public void configureRepositoryRestConfiguration( RepositoryRestConfiguration config ) {
              config.setBasePath( Routes.PRIVATE );
          }
      }
      

      in this way one could write a generic controller with a known subpath, such as /register, but then attach it in the final application as, in my case, /v0/public/register. Suggestions for more flexibility might be a way to setBasePath, explicitly based on annotation.

      so you could write config.setBasePath( PublicController.class, "/v0/public" ) where @PublicController is an extension of @Controller, or maybe it'd just be a good idea to allow it for the specific class instead

      one of the reasons I have this problem is I'm modularizing all of my components, but now I have to ensure that these paths are configured properly for hateoas before writing a controller, because the controllers path is static, thus changes to hateoas roots for links have to be made before the controller for tests. If I could change the base path of the controller later then I could bundle the controllers under a configuration, and they'd be more reusable modules between apps, and completely configurable.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              xenoterracide Caleb Cushing
              Last updater:
              Spring Issues Spring Issues
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 24 weeks, 4 days ago