Best Practice for Errors in RESTful API

后端 未结 3 782
暗喜
暗喜 2021-01-02 08:03

What are the best practices for returning HTTP status codes in RESTful API? I am using Laravel 4 for my PHP framework.

In the case of an error, should I use

3条回答
  •  礼貌的吻别
    2021-01-02 08:44

    I wouldn't use 200 status for everything. That just would be confusing.

    Jquery allows you to process different response codes differently, there are built in methods for that already so take advantage of using them in your apps and when your app grows you can provide that API for others to use too.

    Edit: Also I highly recommend watching this talk about Laravel and API development:

    http://kuzemchak.net/blog/entry/laracon-slides-and-video

提交回复
热议问题