1-认识RestfullApi

1-认识RestfullApi

Restful 风格

最基础的两点

1.动词 使用五种 HTTP 方法,对应 CRUD 操作.

2.我们的资源存放在url里

常规

//添加用户
http://localhost/createuser
//删除id为1的用户
http://localhost/deleteuser?userid=1
//获取用户列表
http://localhost/getuser
//获取id为1的用户
http://localhost/getuser?userid=1
//更新id为1的用户
http://localhost/updateuser?userid=1

Restfull

使用GET的方式请求http://localhost/user代表查询用户列表

使用GET的方式请求http://localhost/user/1代表查询id为1的用户

使用POST的方式请求http://localhost/user代表创建一个用户

使用PUT的方式请求http://localhost/user/1代表修改id为1的用户

使用DELETE的方式请求http://localhost/user/1代表删除id为1的用户。

入门你只要能做到这两点就很不错了

转载自https://bxshare.top/index.php/archives/10/

posted @   ABSchurke  阅读(34)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示