本文整理汇总了Java中org.springframework.web.reactive.HandlerMapping类的典型用法代码示例。如果您正苦于以下问题:Java HandlerMapping类的具体用法?Java HandlerMapping怎么用?Java HandlerMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HandlerMapping类属于org.springframework.web.reactive包,在下文中一共展示了HandlerMapping类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: webSocketMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
HandlerMapping webSocketMapping(CommentService commentService) {
Map<String, WebSocketHandler> urlMap = new HashMap<>();
urlMap.put("/topic/comments.new", commentService);
Map<String, CorsConfiguration> corsConfigurationMap =
new HashMap<>();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("http://localhost:8080");
corsConfigurationMap.put(
"/topic/comments.new", corsConfiguration);
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setOrder(10);
mapping.setUrlMap(urlMap);
mapping.setCorsConfigurations(corsConfigurationMap);
return mapping;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:20,代码来源:WebSocketConfig.java
示例2: webSocketMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
HandlerMapping webSocketMapping(CommentService commentService,
InboundChatService inboundChatService,
OutboundChatService outboundChatService) {
SimpleUrlHandlerMapping mapping =
configureUrlMappings(commentService, inboundChatService, outboundChatService);
Map<String, CorsConfiguration> corsConfigurationMap = new HashMap<>();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(chatConfigProperties.getOrigin());
mapping.getUrlMap().keySet().forEach(route ->
corsConfigurationMap.put(route, corsConfiguration)
);
mapping.setCorsConfigurations(corsConfigurationMap);
return mapping;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:20,代码来源:WebSocketConfig.java
示例3: handlerMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping handlerMapping() {
Map<String, WebSocketHandler> mappings = new HashMap<>(2);
mappings.put("/in", session -> {
session.receive()
.map(WebSocketMessage::getPayloadAsText)
.log()
.subscribe(out::onNext);
return session.send(Mono.just(session.textMessage(MESSAGE_HELLO))).then(session.send(in.map(session::textMessage)));
});
mappings.put("/out", session -> {
session.receive()
.map(WebSocketMessage::getPayloadAsText)
.log()
.subscribe();
return session.send(Mono.just(session.textMessage(MESSAGE_HELLO))).then(session.send(out.map(session::textMessage)));
});
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setUrlMap(mappings);
mapping.setOrder(10);
return mapping;
}
示例4: webSocketMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
HandlerMapping webSocketMapping(CommentService commentService,
InboundChatService inboundChatService,
OutboundChatService outboundChatService) {
Map<String, WebSocketHandler> urlMap = new HashMap<>();
urlMap.put("/topic/comments.new", commentService);
urlMap.put("/app/chatMessage.new", inboundChatService);
urlMap.put("/topic/chatMessage.new", outboundChatService);
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setOrder(10);
mapping.setUrlMap(urlMap);
return mapping;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:16,代码来源:WebSocketConfig.java
示例5: webSocketMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
HandlerMapping webSocketMapping(CommentService commentService,
InboundChatService inboundChatService,
OutboundChatService outboundChatService) {
Map<String, WebSocketHandler> urlMap = new HashMap<>();
urlMap.put("/topic/comments.new", commentService);
urlMap.put("/app/chatMessage.new", inboundChatService);
urlMap.put("/topic/chatMessage.new", outboundChatService);
Map<String, CorsConfiguration> corsConfigurationMap =
new HashMap<>();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("http://localhost:8080");
corsConfigurationMap.put(
"/topic/comments.new", corsConfiguration);
corsConfigurationMap.put(
"/app/chatMessage.new", corsConfiguration);
corsConfigurationMap.put(
"/topic/chatMessage.new", corsConfiguration);
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setOrder(10);
mapping.setUrlMap(urlMap);
mapping.setCorsConfigurations(corsConfigurationMap);
return mapping;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:28,代码来源:WebSocketConfig.java
示例6: webSocketMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
HandlerMapping webSocketMapping(CommentService commentService,
InboundChatService inboundChatService,
OutboundChatService outboundChatService) {
Map<String, WebSocketHandler> urlMap = new HashMap<>();
urlMap.put("/topic/comments.new", commentService);
urlMap.put("/app/chatMessage.new", inboundChatService);
urlMap.put("/topic/chatMessage.new", outboundChatService);
// tag::cors[]
Map<String, CorsConfiguration> corsConfigurationMap =
new HashMap<>();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("http://localhost:8080");
corsConfigurationMap.put(
"/topic/comments.new", corsConfiguration);
corsConfigurationMap.put(
"/app/chatMessage.new", corsConfiguration);
corsConfigurationMap.put(
"/topic/chatMessage.new", corsConfiguration);
// end::cors[]
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setOrder(10);
mapping.setUrlMap(urlMap);
mapping.setCorsConfigurations(corsConfigurationMap);
return mapping;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:30,代码来源:WebSocketConfig.java
示例7: webSocketMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping webSocketMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/react", messageWebSocketHandler);
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setOrder(10);
mapping.setUrlMap(map);
return mapping;
}
示例8: handlerMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping handlerMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/echo", new EchoWebSocketHandler());
map.put("/posts", new PostsWebSocketHandler(this.posts));
// map.put("/custom-header", new CustomHeaderHandler());
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setUrlMap(map);
return mapping;
}
示例9: applicationContext
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
private static ApplicationContext applicationContext(WebFilter... webFilters) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
for(WebFilter filter : webFilters) {
context.registerBean(WebFilter.class, () -> filter);
}
context.registerBean("webHandler", DispatcherHandler.class, () -> new DispatcherHandler());
context.registerBean(HandlerMapping.class, () -> RouterFunctions.toHandlerMapping(request -> Mono.just(r -> ServerResponse.ok().build())));
context.registerBean(HandlerAdapter.class, () -> new HandlerFunctionAdapter());
context.registerBean(HandlerResultHandler.class, () -> new ServerResponseResultHandler());
context.refresh();
return context;
}
示例10: handlerMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping handlerMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/echo", new EchoWebSocketHandler());
map.put("/sub-protocol", new SubProtocolWebSocketHandler());
map.put("/custom-header", new CustomHeaderHandler());
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setUrlMap(map);
return mapping;
}
示例11: handlerMapping
import org.springframework.web.reactive.HandlerMapping; //导入依赖的package包/类
@Bean
public HandlerMapping handlerMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/websocket/echo", new EchoWebSocketHandler());
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setUrlMap(map);
return mapping;
}