You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Something we will follow:

  • for unknown attributes in the request, we will throw an error with a whole list of all of them

  • for all the response, we prefer HATEOAS, such as: return resource link in the response of create/update/delete; add resource url for sub resources(region/indexes)

  • http status code: 201 and 409 for create, 200 and 404 for delete,  200 and 404 for put to update

  • camelCase is for all the key in the request and response body

Long running request:

Rebalance

rebalance request: http POST https://localhost/configurations/rebalance

response:  202 Accepted, Location: /configurations/rebalance

subsequent rebalance request would get the same result: (if a rebalance is already going on, the request is simply accepted, but ignored)


status request: http: GET https://localhost/configurations/rebalance

response if rebalance is still running: 200 Ok, <response> <status>PENDING</status> <start-time>timestamp</start-time> <link rel="cancel" method="delete" href="/configurations/rebalance" /> </response>

response if no rebalance is done: 200 Ok, <response> <status>done</status> <start-time>2 mins.</start-time><end-time>timestamp</end-time></response>

some refer:

1 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md

2 https://developer.github.com/v3/

3 https://codeplanet.io/principles-good-restful-api-design/

4 https://blog.florimond.dev/restful-api-design-13-best-practices-to-make-your-users-happy

5 https://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/

6 https://google.github.io/styleguide/jsoncstyleguide.xml

  • No labels