org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping Java Examples
The following examples show how to use
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebFluxConfigurationSupport.java From spring-analysis-note with MIT License | 6 votes |
@Bean public RequestMappingHandlerMapping requestMappingHandlerMapping( RequestedContentTypeResolver webFluxContentTypeResolver) { RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping(); mapping.setOrder(0); mapping.setContentTypeResolver(webFluxContentTypeResolver); mapping.setCorsConfigurations(getCorsConfigurations()); PathMatchConfigurer configurer = getPathMatchConfigurer(); Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch(); if (useTrailingSlashMatch != null) { mapping.setUseTrailingSlashMatch(useTrailingSlashMatch); } Boolean useCaseSensitiveMatch = configurer.isUseCaseSensitiveMatch(); if (useCaseSensitiveMatch != null) { mapping.setUseCaseSensitiveMatch(useCaseSensitiveMatch); } Map<String, Predicate<Class<?>>> pathPrefixes = configurer.getPathPrefixes(); if (pathPrefixes != null) { mapping.setPathPrefixes(pathPrefixes); } return mapping; }
Example #2
Source File: WebFluxConfigurationSupportTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void requestMappingHandlerMapping() throws Exception { ApplicationContext context = loadConfig(WebFluxConfig.class); final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator"); ReflectionUtils.makeAccessible(field); String name = "requestMappingHandlerMapping"; RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class); assertNotNull(mapping); assertEquals(0, mapping.getOrder()); PathPatternParser patternParser = mapping.getPathPatternParser(); assertNotNull(patternParser); boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser); assertTrue(matchOptionalTrailingSlash); name = "webFluxContentTypeResolver"; RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class); assertSame(resolver, mapping.getContentTypeResolver()); ServerWebExchange exchange = MockServerWebExchange.from(get("/path").accept(MediaType.APPLICATION_JSON)); assertEquals(Collections.singletonList(MediaType.APPLICATION_JSON), resolver.resolveMediaTypes(exchange)); }
Example #3
Source File: WebFluxConfigurationSupportTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void customPathMatchConfig() { ApplicationContext context = loadConfig(CustomPatchMatchConfig.class); final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator"); ReflectionUtils.makeAccessible(field); String name = "requestMappingHandlerMapping"; RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class); assertNotNull(mapping); PathPatternParser patternParser = mapping.getPathPatternParser(); assertNotNull(patternParser); boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser); assertFalse(matchOptionalTrailingSlash); Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods(); assertEquals(1, map.size()); assertEquals(Collections.singleton(new PathPatternParser().parse("/api/user/{id}")), map.keySet().iterator().next().getPatternsCondition().getPatterns()); }
Example #4
Source File: WebFluxConfigurationSupport.java From java-technology-stack with MIT License | 6 votes |
@Bean public RequestMappingHandlerMapping requestMappingHandlerMapping() { RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping(); mapping.setOrder(0); mapping.setContentTypeResolver(webFluxContentTypeResolver()); mapping.setCorsConfigurations(getCorsConfigurations()); PathMatchConfigurer configurer = getPathMatchConfigurer(); Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch(); if (useTrailingSlashMatch != null) { mapping.setUseTrailingSlashMatch(useTrailingSlashMatch); } Boolean useCaseSensitiveMatch = configurer.isUseCaseSensitiveMatch(); if (useCaseSensitiveMatch != null) { mapping.setUseCaseSensitiveMatch(useCaseSensitiveMatch); } Map<String, Predicate<Class<?>>> pathPrefixes = configurer.getPathPrefixes(); if (pathPrefixes != null) { mapping.setPathPrefixes(pathPrefixes); } return mapping; }
Example #5
Source File: WebFluxConfigurationSupportTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void requestMappingHandlerMapping() throws Exception { ApplicationContext context = loadConfig(WebFluxConfig.class); final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator"); ReflectionUtils.makeAccessible(field); String name = "requestMappingHandlerMapping"; RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class); assertNotNull(mapping); assertEquals(0, mapping.getOrder()); PathPatternParser patternParser = mapping.getPathPatternParser(); assertNotNull(patternParser); boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser); assertTrue(matchOptionalTrailingSlash); name = "webFluxContentTypeResolver"; RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class); assertSame(resolver, mapping.getContentTypeResolver()); ServerWebExchange exchange = MockServerWebExchange.from(get("/path").accept(MediaType.APPLICATION_JSON)); assertEquals(Collections.singletonList(MediaType.APPLICATION_JSON), resolver.resolveMediaTypes(exchange)); }
Example #6
Source File: WebFluxConfigurationSupportTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void customPathMatchConfig() { ApplicationContext context = loadConfig(CustomPatchMatchConfig.class); final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator"); ReflectionUtils.makeAccessible(field); String name = "requestMappingHandlerMapping"; RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class); assertNotNull(mapping); PathPatternParser patternParser = mapping.getPathPatternParser(); assertNotNull(patternParser); boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser); assertFalse(matchOptionalTrailingSlash); Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods(); assertEquals(1, map.size()); assertEquals(Collections.singleton(new PathPatternParser().parse("/api/user/{id}")), map.keySet().iterator().next().getPatternsCondition().getPatterns()); }
Example #7
Source File: WebFluxRegistrationsConfig.java From yue-library with Apache License 2.0 | 5 votes |
@Override public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { if (!apiVersionProperties.isEnabled()) { return WebFluxRegistrations.super.getRequestMappingHandlerMapping(); } log.info("【初始化配置-ApiVersionRequestMappingHandlerMapping】默认配置为true,当前环境为true:Restful API接口版本控制,执行初始化 ..."); return new ApiVersionRequestMappingHandlerMapping(apiVersionProperties); }
Example #8
Source File: PluginConfig.java From pf4j-spring-tutorial with MIT License | 5 votes |
private void registerMvcEndpoints(PluginManager pm) { pm.getExtensions(PluginInterface.class).stream() .flatMap(g -> g.mvcControllers().stream()) .forEach(r -> ((ConfigurableBeanFactory) beanFactory) .registerSingleton(r.getClass().getName(), r)); applicationContext .getBeansOfType(RequestMappingHandlerMapping.class) .forEach((k, v) -> v.afterPropertiesSet()); }
Example #9
Source File: WebFluxConfigurationSupport.java From spring-analysis-note with MIT License | 4 votes |
/** * Override to plug a sub-class of {@link RequestMappingHandlerMapping}. */ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { return new RequestMappingHandlerMapping(); }
Example #10
Source File: DispatcherHandlerErrorTests.java From spring-analysis-note with MIT License | 4 votes |
@Bean public RequestMappingHandlerMapping handlerMapping() { return new RequestMappingHandlerMapping(); }
Example #11
Source File: WebFluxConfigurationSupport.java From java-technology-stack with MIT License | 4 votes |
/** * Override to plug a sub-class of {@link RequestMappingHandlerMapping}. */ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { return new RequestMappingHandlerMapping(); }
Example #12
Source File: DispatcherHandlerErrorTests.java From java-technology-stack with MIT License | 4 votes |
@Bean public RequestMappingHandlerMapping handlerMapping() { return new RequestMappingHandlerMapping(); }