File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,40 @@ class ProcessPodcast implements ShouldQueue
217
217
}
218
218
```
219
219
220
+ ## Routing
221
+
222
+ The final step of setup is to enable asynchronous process routes on a resource. These
223
+ routes allow a client to check the current status of a process.
224
+
225
+ For example, if our ` podcasts ` resource used asynchronous processes when a podcast is
226
+ created, we would need to add the following to our [ route definitions] ( ../basics/routing.md ) :
227
+
228
+ ``` php
229
+ JsonApi::register('default')->withNamespace('Api')->routes(function ($api) {
230
+ $api->resource('podcasts')->async();
231
+ });
232
+ ```
233
+
234
+ This enables the following routes:
235
+
236
+ - ` GET /podcasts/queue-jobs ` : this lists all ` queue-jobs ` resources for the ` podcasts `
237
+ resource type.
238
+ - ` GET /podcasts/queue-jobs/<UUID> ` : this retrieves a specific
9C8F
` queue-jobs ` resource
239
+ for the ` podcasts ` resource type.
240
+
241
+ The resource type ` queue-jobs ` is the name used in the JSON API's recommendation for
242
+ asynchronous processing. If you want to use a resource type, then you can change this
243
+ by editing the ` jobs.resource ` config setting in your API's configuration file.
244
+
245
+ Note that we assume the resource id of a process is a valid UUID. If you use something
246
+ different, then you can pass a constraint into the ` async() ` method, as follows:
247
+
248
+ ``` php
249
+ JsonApi::register('default')->withNamespace('Api')->routes(function ($api) {
250
+ $api->resource('podcasts')->async('^\d+$');
251
+ });
252
+ ```
253
+
220
254
## HTTP Requests and Responses
221
255
222
256
Once you have followed the above instructions, you can now make HTTP requests and receive
You can’t perform that action at this time.
0 commit comments