@@ -37,13 +37,9 @@ Unlike WebSocket, which is only compatible with HTTP 1.x,
37
37
Mercure leverages the multiplexing capabilities provided by HTTP/2
38
38
and HTTP/3 (but also supports older versions of HTTP).
39
39
40
- .. image :: /_images/mercure/demo.gif
41
-
42
- In this recording, the view of the webapp and of the mobile app are updated in
43
- real time when they receive a push sent by the Symfony-backed
44
- API Platform REST server.
45
- We'll learn how to create such web projects with ease in the end of this
46
- documentation entry.
40
+ `In this recording `_ you can see how a Symfony web API leverages Mercure
41
+ and API Platform to update in live a React app and a mobile app (React Native)
42
+ generated using the API Platform client generator.
47
43
48
44
Installation
49
45
------------
@@ -68,8 +64,6 @@ clients.
68
64
69
65
.. image :: /_images/mercure/schema.png
70
66
71
- *Courtesy of Mercure.rocks *
72
-
73
67
An official and open source (AGPL) implementation of a Hub can be downloaded
74
68
as a static binary from `Mercure.rocks `_.
75
69
@@ -100,12 +94,12 @@ The preferred way to configure the Mercure Bundle is using
100
94
Set the URL of your hub as the value of the ``MERCURE_PUBLISH_URL `` env var.
101
95
The ``.env `` file of your project has been updated by the Flex recipe to
102
96
provide example values.
103
- Set it to the URL of the Mercure Hub (`http://localhost:3000/hub ` by default).
97
+ Set it to the URL of the Mercure Hub (`` http://localhost:3000/hub ` ` by default).
104
98
105
99
In addition, the Symfony application must bear a `JSON Web Token `_ (JWT)
106
100
to the Mercure Hub to be authorized to publish updates.
107
101
108
- This JWT should be stored in the `MERCURE_JWT_SECRET ` environment variable.
102
+ This JWT should be stored in the `` MERCURE_JWT_SECRET ` ` environment variable.
109
103
110
104
The JWT must be signed with the same secret key than the one used by
111
105
the Hub to verify the JWT (``aVerySecretKey `` in our example).
@@ -235,6 +229,10 @@ and to use URI Templates as patterns:
235
229
* click on the request to the Mercure hub
236
230
* click on the "EventStream" sub-tab.
237
231
232
+ .. tip ::
233
+
234
+ Test if a URI Template match an URL using `the online debugger `_
235
+
238
236
Async dispatching
239
237
-----------------
240
238
@@ -283,8 +281,6 @@ in a ``Link`` HTTP header.
283
281
284
282
.. image :: /_images/mercure/discovery.png
285
283
286
- *Courtesy of Mercure.rocks *
287
-
288
284
Symfony makes it easy to create ``Link `` headers thanks to
289
285
:doc: `WebLink Component </web_link >`.
290
286
Install it, then use it through the ``AbstractController::addLink `` helper method:
@@ -376,7 +372,7 @@ a JWT containing at least one target marking the update to the Hub.
376
372
377
373
To provide this JWT, the subscriber can use a cookie,
378
374
or a ``Authorization `` HTTP header.
379
- Cookies are automatically sent by the browsers when opening an `EventSource ` connection.
375
+ Cookies are automatically sent by the browsers when opening an `` EventSource ` ` connection.
380
376
They are the most secure and preferred way when the client is a web browser.
381
377
If the client is not a web browser, then using an authorization header is the way to go.
382
378
@@ -543,9 +539,9 @@ hypermedia API, and automatic update broadcasting through the Mercure hub:
543
539
public $status;
544
540
}
545
541
546
- As showcased in the recording, at the beginning of this article,
547
- the API Platform Client Generator also allows to scaffold complete React and React Native
548
- apps from this API. These apps will render the content of Mercure updates in real-time.
542
+ As showcased ` in this recording `_, the API Platform Client Generator also
543
+ allows to scaffold complete React and React Native apps from this API.
544
+ These apps will render the content of Mercure updates in real-time.
549
545
550
546
Checkout `the dedicated API Platform documentation `_ to learn more about
551
547
its Mercure support.
@@ -554,6 +550,7 @@ its Mercure support.
554
550
.. _`Server-Sent Events (SSE)` : https://developer.mozilla.org/fr/docs/Server-sent_events
555
551
.. _`a polyfill` : https://github.com/Yaffle/EventSource
556
552
.. _`high-level implementations` : https://github.com/dunglas/mercure#resources
553
+ .. _`In this recording` : https://www.youtube.com/watch?v=UI1l0JOjLeI
557
554
.. _`API Platform` : https://api-platform.com
558
555
.. _`Mercure.rocks` : https://mercure.rocks
559
556
.. _`API Platform distribution` : https://api-platform.com/docs/distribution/
@@ -562,3 +559,4 @@ its Mercure support.
562
559
.. _`IRI` : https://tools.ietf.org/html/rfc3987
563
560
.. _`practical UI` : https://twitter.com/chromedevtools/status/562324683194785792
564
561
.. _`the dedicated API Platform documentation` : https://api-platform.com/docs/core/mercure/
562
+ .. _`the online debugger` : https://uri-template-tester.mercure.rocks
0 commit comments