Skip to content

Support default URI prefix for web service @RequestMapping [SPR-13882] #18455

@spring-projects-issues

Description

@spring-projects-issues

David Cole opened SPR-13882 and commented

I had opened a ticket in Spring-Boot on this topic and it was suggested I create one on the Spring JIRA I have added the original ticket as the Reference URL.

There doesn't seem to be anyway, short of explicitly prefixing each individual
@RequestMapping
with a default URI like

@RequestMapping(path="*/api/*controller1")

at the top of the @RestController class, where /api is the default. I'm trying to have a clear separation in URL paths between normal application requests and web service requests, allowing me to provide additional security specific to web services.

I have an ongoing StackOverflow post, with no meaningful solution to-date and would like to suggest an enhancement to allow a default URI prefix to be supported somewhere in the Spring Boot application.properties configuration.

http://stackoverflow.com/questions/34801351/how-to-configure-a-default-restcontroller-uri-prefix-for-all-controllers

The result would be, using the example above, that my request mapping would be defined as:

@RequestMapping(path="controller1") 

The resulting URL would resolve to:

/<root_context>/api/controller1

I was hoping for more of a 'building block' approach, like:

@RequestMapping(path="/api")
class BaseController{
    ....
}

@RequestMapping(path="sub-class1")
class SubClassedController1 extends BaseController{
   @RequestMapping(path="get-something") 
   public void getSomething(){
       ...
    }
}

@RequestMapping(path="sub-class2")
class SubClassedController2 extends BaseController{
   @RequestMapping(path="get-something") 
   public void getSomething(){
       ...
    }
}

Resulting in

/api/sub-class1/get-something

and

/api/sub-class2/get-something

Affects: 4.2.3, 5.0.1

Reference URL: spring-projects/spring-boot#4994

Issue Links:

6 votes, 12 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions