File tree Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1717import org .springframework .web .bind .annotation .RestController ;
1818
1919@ RestController
20- @ RequestMapping ("request/ headers" )
20+ @ RequestMapping ("headers" )
2121public class RequestHeadersAPI {
2222 Logger logger = LoggerFactory .getLogger (RequestHeadersAPI .class );
2323
Original file line number Diff line number Diff line change 1+ package com .javaprogram .config ;
2+
3+ import org .slf4j .Logger ;
4+ import org .slf4j .LoggerFactory ;
5+ import org .springframework .boot .web .server .WebServerFactoryCustomizer ;
6+ import org .springframework .boot .web .servlet .server .ConfigurableServletWebServerFactory ;
7+ import org .springframework .context .annotation .Bean ;
8+ import org .springframework .stereotype .Component ;
9+
10+ @ Component
11+ public class SetBasePath {
12+
13+ private Logger logger = LoggerFactory .getLogger (getClass ());
14+
15+ @ Bean
16+ public WebServerFactoryCustomizer <ConfigurableServletWebServerFactory > webServerFactoryCustomizer () {
17+ WebServerFactoryCustomizer <ConfigurableServletWebServerFactory > customizer = factory -> factory
18+ .setContextPath ("/api/v1" );
19+
20+ logger .info ("Setting up the custom base path " );
21+ return customizer ;
22+ }
23+ }
Original file line number Diff line number Diff line change 11package com .javaprogram .springbootapp ;
22
3+ import org .slf4j .Logger ;
4+ import org .slf4j .LoggerFactory ;
35import org .springframework .boot .SpringApplication ;
46import org .springframework .boot .autoconfigure .SpringBootApplication ;
57import org .springframework .context .annotation .ComponentScan ;
810@ SpringBootApplication
911public class SpringBootAppApplication {
1012
13+ private Logger logger = LoggerFactory .getLogger (getClass ());
14+
1115 public static void main (String [] args ) {
1216 SpringApplication .run (SpringBootAppApplication .class , args );
1317 }
@@ -28,4 +32,5 @@ public static void main(String[] args) {
2832// factory.setPort(9000); factory.setContextPath("/myapp");
2933// factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html"));
3034// return factory; }
35+
3136}
Original file line number Diff line number Diff line change 4343# # Number of selector threads to use. When the value is -1.
4444# server.jetty.selectors=2
4545#
46+
47+ server.servlet.context-path =/api/v2
48+ # spring.data.rest.basePath=/api/v1
You can’t perform that action at this time.
0 commit comments