vert.x http 服务器框架
引用
maven
<dependency>
<groupId>io.github.xllyll</groupId>
<artifactId>vertx-boot</artifactId>
<version>0.0.3</version>
</dependency>
使用:
import org.xllyll.vertx.boot.VertxApplication;
public class ServerApplication {
public static void main(String[] args) {
VertxApplication.run(ServerApplication.class);
}
}
api
@RestApi
public class IndexApi {
@RequestMapping(path={"/index"},method = RequestMethod.GET)
public BaseResponse index() {
BaseResponse baseResponse = new BaseResponse();
baseResponse.setData("Hello Vertx Boot");
baseResponse.setMessage("操作成功");
return baseResponse;
}
@RequestMapping(path={"/index/name"},method = RequestMethod.GET)
public BaseResponse indexName(List<Integer> age) {
BaseResponse baseResponse = new BaseResponse();
baseResponse.setMessage("操作成功");
return baseResponse;
}
@RequestMapping(path="/index",method = RequestMethod.GET)
public BaseResponse index(UserDto userDto) {
BaseResponse baseResponse = new BaseResponse();
baseResponse.setMessage("操作成功");
baseResponse.setData(userDto);
return baseResponse;
}
}
访问:http://127.0.0.1:8080/index
返回:{"code":0,"message":"操作成功","data":"Hello Vertx Boot"}