rest-api-web 高效 RESTful API 服务实现 项目简介
高效的 RESTful API 服务实现,基于 Jersey2 和嵌入式的轻量级的 servlet 容器 Jetty9, 这个是 war 包形式部署到 jetty 中运行,实现对用户的增、删、改、查操作,并且严格按照 RESTful 风格设计接口。基于Jersey2 + Spring4 + MyBatis3 + Jetty9 实现,完全遵循 OpenAPI 设计规范,供开发 Web API 的开发人员做一个参考实现,并很容易在此基础上扩展功能。接口演示:根据id获取用户信息http://localhost/api/v1/users/1结果:{
"id" : 1,
"name" : "张飞",
"age" : 20,
"password" : "zhangfei",
"createdTime" : "2017-06-15 20:38:09",
"updatedTime" : "2017-06-15 20:38:09"
} 注:下面几种使用chrome的Postman测试创建新用户http://localhost/api/v1/users POSTbody参数:{
"id" : 3,
"name" : "孙权",
"age" : 24,
"password" : "sunquan"
}返回结果:HTTP code:201
User was successfully created更新用户http://localhost/api/v1/users PUTbody参数:{
"id" : 3,
"name" : "孙权",
"age" : 25,
"password" : "sunquan"
}返回结果:HTTP code:200
User was successfully updated
"id" : 1,
"name" : "张飞",
"age" : 20,
"password" : "zhangfei",
"createdTime" : "2017-06-15 20:38:09",
"updatedTime" : "2017-06-15 20:38:09"
} 注:下面几种使用chrome的Postman测试创建新用户http://localhost/api/v1/users POSTbody参数:{
"id" : 3,
"name" : "孙权",
"age" : 24,
"password" : "sunquan"
}返回结果:HTTP code:201
User was successfully created更新用户http://localhost/api/v1/users PUTbody参数:{
"id" : 3,
"name" : "孙权",
"age" : 25,
"password" : "sunquan"
}返回结果:HTTP code:200
User was successfully updated