Understanding REST: Verbs, error codes, and authentication

后端 未结 10 1806
你的背包
你的背包 2020-11-22 07:39

I am looking for a way to wrap APIs around default functions in my PHP-based web applications, databases and CMSs.

I have looked around and found several \"skeleton

10条回答
  •  心在旅途
    2020-11-22 07:43

    For the examples you stated I'd use the following:

    activate_login

    POST /users/1/activation

    deactivate_login

    DELETE /users/1/activation

    change_password

    PUT /passwords (this assumes the user is authenticated)

    add_credit

    POST /credits (this assumes the user is authenticated)

    For errors you'd return the error in the body in the format that you got the request in, so if you receive:

    DELETE /users/1.xml

    You'd send the response back in XML, the same would be true for JSON etc...

    For authentication you should use http authentication.

提交回复
热议问题