org.springframework.web.servlet.function.RouterFunctions Java Examples
The following examples show how to use
org.springframework.web.servlet.function.RouterFunctions.
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: WebMvcServerDsl.java From spring-fu with Apache License 2.0 | 6 votes |
@Override public void initialize(GenericApplicationContext context) { super.initialize(context); this.dsl.accept(this); context.registerBean(BeanDefinitionReaderUtils.uniqueBeanName(RouterFunction.class.getName(), context), RouterFunction.class, () -> RouterFunctions.route().resources("/**", new ClassPathResource("static/")).build() ); serverProperties.setPort(port); serverProperties.getServlet().setRegisterDefaultServlet(false); if (!convertersConfigured) { new StringConverterInitializer().initialize(context); new ResourceConverterInitializer().initialize(context); } if (context.containsBeanDefinition("webHandler")) { throw new IllegalStateException("Only one webFlux per application is supported"); } new ServletWebServerInitializer(serverProperties, webMvcProperties, resourceProperties).initialize(context); }
Example #2
Source File: HandlerFunctionAdapter.java From spring-analysis-note with MIT License | 5 votes |
private ServerRequest getServerRequest(HttpServletRequest servletRequest) { ServerRequest serverRequest = (ServerRequest) servletRequest.getAttribute(RouterFunctions.REQUEST_ATTRIBUTE); Assert.state(serverRequest != null, () -> "Required attribute '" + RouterFunctions.REQUEST_ATTRIBUTE + "' is missing"); return serverRequest; }
Example #3
Source File: RouterFunctionMapping.java From spring-analysis-note with MIT License | 5 votes |
@Nullable @Override protected Object getHandlerInternal(@NotNull HttpServletRequest servletRequest) throws Exception { if (this.routerFunction != null) { ServerRequest request = ServerRequest.create(servletRequest, this.messageConverters); servletRequest.setAttribute(RouterFunctions.REQUEST_ATTRIBUTE, request); return this.routerFunction.route(request).orElse(null); } else { return null; } }
Example #4
Source File: WebMvcServerDsl.java From spring-fu with Apache License 2.0 | 5 votes |
/** * Configure routes via {@link RouterFunctions.Builder}. * @see org.springframework.fu.jafu.BeanDefinitionDsl#bean(Class, BeanDefinitionCustomizer...) */ public WebMvcServerDsl router(Consumer<RouterFunctions.Builder> routerDsl) { RouterFunctions.Builder builder = RouterFunctions.route(); context.registerBean(BeanDefinitionReaderUtils.uniqueBeanName(RouterFunction.class.getName(), context), RouterFunction.class, () -> { routerDsl.accept(builder); return builder.build(); }); return this; }