You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
用户判断 HTTP status code 比解析body更加简单,另外就是你永远返回200是不是要自己去定义一套返回码?
HTTP 天然适合 CRUD 类的业务,GET PUT DELETE POST,这些已经在 HTTP 协议里面抽象好了,你代码按照这个逻辑去抽象,用户可以无脑使用。
你的业务按照 GET PUT DELETE POST, 对路由设计,log 统计,业务抽象更加容易。我这篇文章里 CreateUser 这个例子,就需要在 HTTP SERVER 入口的地方解析一遍body,然后再把数据丢给对应的业务逻辑接口去处理。而且还不能让每个接口去单独序列化它自己需要的数据结构。
一个 API 设计问题带来的思考
https://www.liyafu.com/2019-09-03-an-api-problem-myth/
The text was updated successfully, but these errors were encountered: