|
| 1 | += RESTful Notes API Guide |
| 2 | +Baeldung; |
| 3 | +:doctype: book |
| 4 | +:icons: font |
| 5 | +:source-highlighter: highlightjs |
| 6 | +:toc: left |
| 7 | +:toclevels: 4 |
| 8 | +:sectlinks: |
| 9 | + |
| 10 | +[[overview]] |
| 11 | += Overview |
| 12 | + |
| 13 | +[[overview-http-verbs]] |
| 14 | +== HTTP verbs |
| 15 | + |
| 16 | +RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its |
| 17 | +use of HTTP verbs. |
| 18 | + |
| 19 | +|=== |
| 20 | +| Verb | Usage |
| 21 | + |
| 22 | +| `GET` |
| 23 | +| Used to retrieve a resource |
| 24 | + |
| 25 | +| `POST` |
| 26 | +| Used to create a new resource |
| 27 | + |
| 28 | +| `PATCH` |
| 29 | +| Used to update an existing resource, including partial updates |
| 30 | + |
| 31 | +| `DELETE` |
| 32 | +| Used to delete an existing resource |
| 33 | +|=== |
| 34 | + |
| 35 | +RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its |
| 36 | +use of HTTP status codes. |
| 37 | + |
| 38 | +|=== |
| 39 | +| Status code | Usage |
| 40 | + |
| 41 | +| `200 OK` |
| 42 | +| The request completed successfully |
| 43 | + |
| 44 | +| `201 Created` |
| 45 | +| A new resource has been created successfully. The resource's URI is available from the response's |
| 46 | +`Location` header |
| 47 | + |
| 48 | +| `204 No Content` |
| 49 | +| An update to an existing resource has been applied successfully |
| 50 | + |
| 51 | +| `400 Bad Request` |
| 52 | +| The request was malformed. The response body will include an error providing further information |
| 53 | + |
| 54 | +| `404 Not Found` |
| 55 | +| The requested resource did not exist |
| 56 | +|=== |
| 57 | + |
| 58 | +[[overview-headers]] |
| 59 | +== Headers |
| 60 | + |
| 61 | +Every response has the following header(s): |
| 62 | + |
| 63 | +include::{snippets}/headers-example/response-headers.adoc[] |
| 64 | + |
| 65 | +[[overview-hypermedia]] |
| 66 | +== Hypermedia |
| 67 | + |
| 68 | +RESTful Notes uses hypermedia and resources include links to other resources in their |
| 69 | +responses. Responses are in http://stateless.co/hal_specification.html[Hypertext Application |
| 70 | +from resource to resource. |
| 71 | +Language (HAL)] format. Links can be found beneath the `_links` key. Users of the API should |
| 72 | +not create URIs themselves, instead they should use the above-described links to navigate |
| 73 | + |
| 74 | +[[resources]] |
| 75 | += Resources |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +[[resources-index]] |
| 80 | +== Index |
| 81 | + |
| 82 | +The index provides the entry point into the service. |
| 83 | + |
| 84 | +[[resources-index-access]] |
| 85 | +=== Accessing the index |
| 86 | + |
| 87 | +A `GET` request is used to access the index |
| 88 | + |
| 89 | +==== Response structure |
| 90 | + |
| 91 | +include::{snippets}/index-example/http-response.adoc[] |
| 92 | + |
| 93 | +==== Example response |
| 94 | + |
| 95 | +include::{snippets}/index-example/http-response.adoc[] |
| 96 | + |
| 97 | +==== Example request |
| 98 | + |
| 99 | +include::{snippets}/index-example/http-request.adoc[] |
| 100 | + |
| 101 | +==== CURL request |
| 102 | + |
| 103 | +include::{snippets}/index-example/curl-request.adoc[] |
| 104 | + |
| 105 | +[[resources-index-links]] |
| 106 | +==== Links |
| 107 | + |
| 108 | +include::{snippets}/index-example/links.adoc[] |
| 109 | + |
| 110 | + |
| 111 | +[[resources-CRUD]] |
| 112 | +== CRUD REST Service |
| 113 | + |
| 114 | +The CRUD provides the entry point into the service. |
| 115 | + |
| 116 | +[[resources-crud-access]] |
| 117 | +=== Accessing the crud GET |
| 118 | + |
| 119 | +A `GET` request is used to access the CRUD read |
| 120 | + |
| 121 | +==== Response structure |
| 122 | + |
| 123 | +include::{snippets}/crud-get-example/http-request.adoc[] |
| 124 | + |
| 125 | +==== Example response |
| 126 | + |
| 127 | +include::{snippets}/crud-get-example/http-response.adoc[] |
| 128 | + |
| 129 | +==== CURL request |
| 130 | + |
| 131 | +include::{snippets}/crud-get-example/curl-request.adoc[] |
| 132 | + |
| 133 | +[[resources-crud-access]] |
| 134 | +=== Accessing the crud POST |
| 135 | + |
| 136 | +A `POST` request is used to access the CRUD create |
| 137 | + |
| 138 | +==== Response structure |
| 139 | + |
| 140 | +include::{snippets}/crud-create-example/http-request.adoc[] |
| 141 | + |
| 142 | +==== Example response |
| 143 | + |
| 144 | +include::{snippets}/crud-create-example/http-response.adoc[] |
| 145 | + |
| 146 | +==== CURL request |
| 147 | + |
| 148 | +include::{snippets}/crud-create-example/curl-request.adoc[] |
| 149 | + |
| 150 | +[[resources-crud-access]] |
| 151 | +=== Accessing the crud DELETE |
| 152 | + |
| 153 | +A `DELETE` request is used to access the CRUD create |
| 154 | + |
| 155 | +==== Response structure |
| 156 | + |
| 157 | +include::{snippets}/crud-delete-example/http-request.adoc[] |
| 158 | + |
| 159 | +==== Example response |
| 160 | + |
| 161 | +include::{snippets}/crud-delete-example/http-response.adoc[] |
| 162 | + |
| 163 | +==== CURL request |
| 164 | + |
| 165 | +include::{snippets}/crud-delete-example/curl-request.adoc[] |
| 166 | + |
| 167 | +[[resources-crud-access]] |
| 168 | +=== Accessing the crud PATCH |
| 169 | + |
| 170 | +A `PATCH` request is used to access the CRUD create |
| 171 | + |
| 172 | +==== Response structure |
| 173 | + |
| 174 | +include::{snippets}/crud-patch-example/http-request.adoc[] |
| 175 | + |
| 176 | +==== Example response |
| 177 | + |
| 178 | +include::{snippets}/crud-patch-example/http-response.adoc[] |
| 179 | + |
| 180 | +==== CURL request |
| 181 | + |
| 182 | +include::{snippets}/crud-patch-example/curl-request.adoc[] |
| 183 | + |
| 184 | +[[resources-crud-access]] |
| 185 | +=== Accessing the crud PUT |
| 186 | + |
| 187 | +A `PUT` request is used to access the CRUD create |
| 188 | + |
| 189 | +==== Response structure |
| 190 | + |
| 191 | +include::{snippets}/crud-put-example/http-request.adoc[] |
| 192 | + |
| 193 | +==== Example response |
| 194 | + |
| 195 | +include::{snippets}/crud-put-example/http-response.adoc[] |
| 196 | + |
| 197 | +==== CURL request |
| 198 | + |
| 199 | +include::{snippets}/crud-put-example/curl-request.adoc[] |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
0 commit comments