Debian Codegraph @

www/src/content/essays/rest-copypasta.md

raw symbols SCIP
1 ---
2 title: "REST Copypasta"
3 description: "These page provides some pre-written critiques of the common misuse of the term 'REST' in modern web development, contrasting it with the true REST architecture defined by Roy Fielding. Copy these ready-made responses to helpfully explain how JSON/RPC is often mislabeled as REST and highlight the role of hypermedia and API specifications in defining REST-ful systems. You will surely not make any enemies or regret posting these responses in any way."
4 created: 2023-06-26
5 modified: 2023-06-26
6 authors: [ "Carson Gross" ]
7 tags: ["foundations"]
8 #show_title: false
9 #show_author: false
10 ---
11
12 ## REST copy-pastas
13
14 ## Ackshually...
15
16 <div style="font-family: monospace">
17
18 I'd just like to interject for a moment. What you're referring to as REST,
19 is in fact, JSON/RPC, or as I've recently taken to calling it, REST-less.
20 JSON is not a hypermedia unto itself, but rather a plain data format made
21 useful by out of band information as defined by swagger documentation or
22 similar.
23
24 Many computer users work with a canonical version of REST every day,
25 without realizing it. Through a peculiar turn of events, the version of REST
26 which is widely used today is often called "The Web", and many of its users are
27 not aware that it is basically the REST-ful architecture, defined by Roy Fielding.
28
29 There really is a REST, and these people are using it, but it is just a
30 part of The Web they use. REST is the network architecture: hypermedia encodes the state
31 of resources for hypermedia clients. JSON is an essential part of Single Page Applications,
32 but useless by itself; it can only function in the context of a complete API specification.
33 JSON is normally used in combination with SPA libraries: the whole system
34 is basically RPC with JSON added, or JSON/RPC. All these so-called "REST-ful"
35 APIs are really JSON/RPC.
36
37 </div>
38 <button _="on click
39 get the innerText of the previous <div/>
40 then writeText(the result) with the navigator's clipboard
41 put 'Copied!' into the next <output/>
42 wait 2s
43 put '' into the next <output/>">
44 Copy
45 </button>
46 <button _="on click
47 get the innerText of the previous <div/>
48 get result.split('\n').map( \ l -> ' ' + l ).join('\n')
49 then writeText(the result) with the navigator's clipboard
50 put 'Copied for HN!' into the next <output/>
51 wait 2s
52 put '' into the next <output/>">
53 Copy For HN
54 </button>
55 <output></output>
56
57 <br/>
58
59 ## l໐, t໐ thē ¢໐ຖtrคrฯ
60
61 <div style="font-family: monospace">
62
63 In a world of digital wonder, allow me to take a moment to clarify. What many name as REST is, in truth, JSON/RPC, or as
64 I've lately begun to refer to it, the REST-less. JSON is not a magical script unto itself, but rather a simple parchment
65 of data made meaningful by wisdom from unseen sources, shaped by the likes of the Swagger tomes and their ilk.
66
67 Countless keepers of the code interact with a revered form of REST each day, oblivious to its presence. Through an
68 unexpected twist of fate, the interpretation of REST most commonly employed today is frequently dubbed "The Web", and
69 many of its inhabitants are unaware that they are, in essence, dwelling within the architectural dominion of REST, as
70 laid out by the sage Roy Fielding.
71
72 Indeed, there exists a true REST, and these individuals are making use of it, but it is merely a facet of The Web they
73 engage with. REST is the great network architecture: hypermedia inscribes the state of resources for the hypermedia
74 voyagers. JSON is a vital element of Single Page Applications, yet worthless in solitude; it can only exhibit its power
75 within the realm of a comprehensive API specification. JSON is typically deployed in alliance with SPA libraries: the
76 entire realm is fundamentally RPC embellished with JSON, or JSON/RPC. All these entities hailed as "REST-ful" APIs are
77 in actuality, the embodiment of JSON/RPC.
78
79 </div>
80 <button _="on click
81 get the innerText of the previous <div/>
82 then writeText(the result) with the navigator's clipboard
83 put 'Copied!' into the next <output/>
84 wait 2s
85 put '' into the next <output/>">
86 Copy
87 </button>
88 <button _="on click
89 get the innerText of the previous <div/>
90 get result.split('\n').map( \ l -> ' ' + l ).join('\n')
91 then writeText(the result) with the navigator's clipboard
92 put 'Copied for HN!' into the next <output/>
93 wait 2s
94 put '' into the next <output/>">
95 Copy For HN
96 </button>
97 <output></output>