基于node.js + koa2搭建的restfulapi demo,扩展自learn-javascript,基本涵盖了主要的api类型,联动文章:编写 部署
#Usage
项目目录下执行,node start
-
GET (json)
http://localhost:3000/api/geeknews/version
http://localhost:3000/api/products
-
GET (image)
http://localhost:3000/img/test.jpg
-
GET (file)
http://localhost:3000/apk/geeknews.apk
-
POST (json)
http://localhost:3000/api/products
body {"name":"XBox","price":3999} -
DELETE (json)
http://localhost:3000/api/products/p1