-
Notifications
You must be signed in to change notification settings - Fork 55
Configuration basics
Mariusz Kopylec edited this page Jun 9, 2019
·
9 revisions
Charon can be configured in many ways.
This can be done via CharonConfigurer
API.
Charon can be configured globally or per request mapping.
Request mapping configuration always overwrites the global one for a particular mapping.
For example if Charon is configured like below:
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"))
.add(requestMapping("mapping 1"))
.add(requestMapping("mapping 2")
.set(requestServerNameRewriter().outgoingServers("host2:8081")));
}
}
then requests handled by mapping 1
mapping wil be forwarded to http://host1:8080 but those handled by mapping 2
mapping will be forwarded to http://host2:8081.