More questions on RESTful URIs

Numeric identifiers and names

As an example, which one would you choose to identify one transaction, from one bank account, for one company:

  • / company / freds-paint-ltd / account / savings / operation / 4831
  • / companies / freds-painting-ltd / accounts / 1 / operations / 4831
  • / companies / 62362 / accounts / 1 / operations / 4831
  • You idiot, something completely different! Cries, did you even read Fielding’s dissertation?

Now I think the first one is the most readable. If I have several companies, or if I am someone like an accountant managing several companies, he immediately finds out which company and which account I am looking at. It is also more classified / accessible by email and will prevent a “trap” for other companies by changing the company identifier. I would like transaction identifiers to be unique to the account (Ie Both savings and current accounts could have transaction "1"

"Company" will be my "top level" or "first class" resource. Nothing at all would be shared between companies. Thus, it would be an ideal candidate for a shard (or "ancestral space" / "namespace" in the Google App Engine language). Therefore, I only need to worry about the fact that account names are unique in one company. Each company can have an account called "savings."

Not sure what the situation is like in the rest of the world, although LTD or PLC in the UK will have a unique name, there may be many Dave Window Cleaning businesses (what is known as a trade name).

, URI //- , , -, .., , , .

, /:

1) , - , , : ", Dave Window Cleaning". " Dave Portsmouth" ( )? , , , - . , biggie.

2) . , " Dave Window, "? , URL-, "daves-window-cleaning-gardening-and-load-of-other-stuff/'

3) -, - , , , . URI 404, , , - , .

4) "" - , , , .

5) .

6) URL-, GAE , .

RESTful webservice vs - RESTful

, - RESTful, iphone/android ( ). ? , URL, , "RESTful":/questions/ask - . "ask" . , POSTing/questions/- , PUTing to/questions/{id}

, Stackoverflow URI, /questions/ 362352/name-of-the-question, , ​​ .

webapp, - ( )? REST- (JSON/XML) HTTP-, ( ) ?

, /company/aboxo/ HTML- ( stringtemplate.org), GET/, text/plain test/html, JSON/XML ?

"//"? GET//company/freds-painting-ltd/saving/transaction/? Template = add ( GET../transactions/352?template=edit), HTML?

- .

, , - !

+3
2

Rails "id vs name", URL-, , , :

/companies/62362-freds-painting-ltd/accounts/1-savings/transactions/4831

ie - , " url", , , , ... , : , .

, , , , URL-, :

/companies/62362-i_luv_blue_turtles/accounts/1-your_mum/transactions/4831

:

/companies/62362/accounts/1/transactions/4831

:)

0

URI /transactions/{id}, , , . , # 4: -)

SEO ? , , Google X?! ( ) URI.

0

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


All Articles