-
Notifications
You must be signed in to change notification settings - Fork 56
Basic usage
Mariusz Kopylec edited this page Jun 9, 2019
·
2 revisions
Create a Spring Boot web application:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Configure Charon by creating a CharonConfigurer
Spring bean:
import static com.github.mkopylec.charon.configuration.CharonConfigurer.charonConfiguration;
import static com.github.mkopylec.charon.configuration.RequestMappingConfigurer.requestMapping;
import static com.github.mkopylec.charon.forwarding.interceptors.rewrite.RequestServerNameRewriterConfigurer.requestServerNameRewriter;
@Configuration
class CharonConfiguration {
@Bean
CharonConfigurer charonConfigurer() {
return charonConfiguration()
.set(requestServerNameRewriter().outgoingServers("host1:8080", "host2:8081"))
.add(requestMapping("all requests mapping"));
}
}
When an application is configured like above then every incoming request will be forwarded to http://host1:8080 or http://host2:8081.