普通接口设计
1.只用到get和post接口
2.接口的地址一般由动词+名词构成
3.每个接口的地址都不一样
例如:
接口名:localhost:8080/getarticle 类型:get 功能:获取文章信息
接口名:localhost:8080/addarticle 类型:post 功能:添加新文章
接口名:localhost:8080/delarticle 类型:post 功能:删除文章
接口名:localhost:8080/updatearticle 类型:post 功能:编辑文章
普通的api设计:
app.get('/getarticle',(req,res)=>{
res.send('获取')
})
app.post('/addarticle',(req,res)=>{
res.send('添加')
})
app.post('/delarticle',(req,res)=>{
res.send('删除')
})
app.post('/updatearticle',(req,res)=>{
res.send('编辑')
})