7 ms·
As a shorthand, think of REST as about nouns, and RPC about verbs. /account/1 is REST because the you're looking for an account (noun), the account id is 1, an
by michaelchisari 9y ago
As a shorthand, think of REST as about nouns, and RPC about verbs.
/account/1 is REST because the you're looking for an account (noun), the account id is 1, and you're using the HTTP method GET.
/search/hello is RPC because it uses a specific verb (search) to call a remote procedure to search for the 'hello' keyword. You're taking an action for which there is no appropriate HTTP method, so RPC can be used instead of REST.
This doesn't cover 100% of every situation, but it's useful as a quick mnemonic.
- dragonwriter 9y ago> /account/1 is REST Probably not. If "what this is and how it relates to other things" is determined by looking at the URL path and not the media type (for "what it is") and link relationshops (for how it relates to other things) it's not REST.
- deleted 9y ago[deleted]
- shados 9y agoAnd that's the issue. Most engineers don't understand HTTP. Just the amount of people who confuse PUT and POST is pretty high. Getting people to remember that media type exists is hard. Add in the rest, it's just not happening. But the unicorn "properly designed REST api" is quite nice. Since i can't trust anyone to do it right though, I'll just use GraphQL because its easier to get people to do right.
- michaelchisari 9y agoReading over your comments, I'm curious what you would consider to be an API that properly implements REST principles according to the original dissertation.
- naasking 9y agoThat's incorrect. REST has no such restrictions on URLs. URLs can be completely random numbers with no human-discernible meaning. REST is about architecture, about where state should live, how long it should live, how messages between entities should designate resources/state, all so you can preserve encapsulation and maximal flexibility for service upgrade. Your service is not RESTful if you don't meet these criteria. RPC has no such restrictions, which means you're free to do everything wrong, which virtually everyone does, and you'll still be doing RPC correctly.