REST interface for searching medium

Suppose I want to create a REST interface to look up the average number of numbers. Suppose numbers are served one at a time. How do you do this?

Is this right to do? Any suggestions?

+5
source share
4 answers

. , URL- /list/{id}, {id} . :

  • POST /list , ( "" ) URL /list/{id} Location.
  • POST /list/{id}
  • GET /list/{id}/average
  • DELETE /list/{id} .

GET /list/{id}/average GET /list/{id}, , . XML, .

+7

, , ( ) ( ).

:

  • - , . , , - . .
  • - , / .
  • Idempotent - . , .

HTTP:

  • GET - . , . (idempotent, cacheable)
  • DELETE - . . ( , )
  • PUT - ( , ). (, )
  • POST - , . . ( ) , , ).

, POST 'create'. , POST "" REST. : http://www.markbaker.ca/2001/09/draft-baker-http-resource-state-model-01.txt ( 3.1.4).

POST , HTTP , . , , REST.

, :

  • : POST
  • :
  • : ( )

- SOAP, . SOAP POST .

KISS ( , ).

0

, URI URI . URI, API, , API REST.

0

REST,

Do PUTthis to indicate a new structure that generates a hash, that is, not based on the number passed. Just a "random" hash. Then each subsequent record would include id-hash with a returned hash of the result of the sent numbers. Then, when you get the idea that you can cache the results.

1. PUT    /api/average/{number} //return id-hash
2. POST   /api/average/{id-hash}/{number} // return average-hash
3. GET    /api/average/{average-hash}
4. DELETE /api/average/{id-hash}

You can then cache the average hash, even if you can get the result differently, or different servers get the same average.

-1
source

All Articles