GET or PUT for a REST request

I have a situation where a client application can request a resource that meets certain criteria, and if the corresponding resource does not exist, it is created and cached. Subsequent requests for the same criteria return a cached resource.

I could implement this with a PUT request to create a resource and subsequent GETs. However, in my specific scenario, which requires the client to know too much about the internal workings of my system, that is, the client does not care if the resource exists or not.

So what is it ReSTful to allow the client to make one GET request that occurs to create the resource if it does not already exist?

+3
source share
4 answers

GET GET, . . idempotency.

:

(, HEAD, GET, OPTIONS TRACE) , , .

GET . , , GET .

+6

GET ; "" HTTP, , " ", , .

, , , , + . , - " " , " " .

GET/resource? criteria1 = xyz & criteria2 = abc

+3

, - . , GET, . , ( ), .

: , GET , . EDIT: , , : -)

+1

GET, POST - .

GET - , , .

, GET , , .

0

Source: https://habr.com/ru/post/1731343/


All Articles