Hello Reactive
1、添加依赖
只需要在原有的 web 项目基础上,添加响应式接口插件即可
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-web-rx</artifactId>
</dependency>
2、开始编码
public class DemoApp {
public static void main(String[] args){
Solon.start(DemoApp.class, args);
}
}
@Controller
public class DemoController {
//经典的
@Mapping("/hi")
public String hi(String name) {
return "Hello " + name;
}
//响应式的
@Mapping("/hello")
public Mono<String> hello(String name) {
return Mono.fromSupplier(() -> {
return "Hello " + name;
});
}
}