Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST: Why use logical URIs?

Tags:

rest

uri

Other than readability, why would you use logical URIs?

Surely sending a GET request to /users (to get all users) is the same as /users.php

Surely sending POST to /users/dave with some data to update Dave is the same as /users.php?name=dave&phone=1234

You decide what to do based on the HTTP method, and then you pull apart the URI string anyway.

like image 659
Jobbo Avatar asked Feb 03 '26 06:02

Jobbo


1 Answers

Logical URIs decouple client code from the implementation details of the server-side code. In your /users.php example, .php is an implementation detail. If I publish that URI as an endpoint, clients will depend on that specific PHP script. I won't be able to switch to a Java or .NET implementation without changing client code. (Or I'd have to do some really unsavory remappings on the server.)

like image 157
Bill the Lizard Avatar answered Feb 04 '26 21:02

Bill the Lizard