mkopylec / charon-spring-boot-starter

Reverse proxy implementation in form of a Spring Boot starter.
Apache License 2.0
248 stars 55 forks source link

how to map multi uri pattern? #112

Closed sendreams closed 4 years ago

sendreams commented 4 years ago

hi, below is my code.

`@Configuration public class CharonConfiguration {

@Resource
private DispatchProperties dispatchProperties;

@Bean
CharonConfigurer charonConfigurer(CacheServerRepository cacheServerRepository,
                                    CadServerRepository cadServerRepository,
                                    TileGet tileGet,
                                    @Value("${ware4u.tile.cacheAge}") int cacheAge) {

    return charonConfiguration()
            .set(restTemplate()
                    .set(timeout().connection(Duration.ofMillis(dispatchProperties.getConnection()))
                            .read(Duration.ofMillis(dispatchProperties.getRead()))
                            .write(Duration.ofMillis(dispatchProperties.getWrite()))))

            .set(CadInterceptorConfigurer.configurer()
                        .repository(cadServerRepository))
                .add(requestMapping("cad").pathRegex("/api/data/cad/.*"))

            .set(CacheInterceptorConfigurer.configurer()
                        .repository(cacheServerRepository)
                        .tileGet(tileGet)
                        .cacheAge(cacheAge))
                .add(requestMapping("tile").pathRegex("/tile/.*"));
}

}`

i have add two interceptor and each one mapping a uri pattern. but in fact, only the last interceptor can be working.

is any wrong here? tks.

sendreams commented 4 years ago

hi, i solve the issue, just set the InterceptorConfigurer's type to different type, if is use same type will replace the InterceptorConfigurer.