Convention for HTTP response header to notify clients of deprecated API

前端 未结 6 671
逝去的感伤
逝去的感伤 2020-12-23 16:00

I\'m upgrading our REST API endpoints and I want to notify clients when they are calling the to-be-deprecated endpoint.
What header should I use in the response with a m

6条回答
  •  醉话见心
    2020-12-23 16:14

    You could use 410 (Gone).

    Here's how W3C's Status Code Definitions describe it:

    410 (Gone)

    The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.

    The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient that the resource is intentionally unavailable and that the server owners desire that remote links to that resource be removed. Such an event is common for limited-time, promotional services and for resources belonging to individuals no longer working at the server's site. It is not necessary to mark all permanently unavailable resources as "gone" or to keep the mark for any length of time -- that is left to the discretion of the server owner.

提交回复
热议问题