Skip to content

Commit 5178d72

Browse files
committed
Review
1 parent 77c3b43 commit 5178d72

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

_images/mercure/demo.gif

-3.67 MB
Binary file not shown.

mercure.rst

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ Unlike WebSocket, which is only compatible with HTTP 1.x,
3737
Mercure leverages the multiplexing capabilities provided by HTTP/2
3838
and HTTP/3 (but also supports older versions of HTTP).
3939

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.
4743

4844
Installation
4945
------------
@@ -68,8 +64,6 @@ clients.
6864

6965
.. image:: /_images/mercure/schema.png
7066

71-
*Courtesy of Mercure.rocks*
72-
7367
An official and open source (AGPL) implementation of a Hub can be downloaded
7468
as a static binary from `Mercure.rocks`_.
7569

@@ -100,12 +94,12 @@ The preferred way to configure the Mercure Bundle is using
10094
Set the URL of your hub as the value of the ``MERCURE_PUBLISH_URL`` env var.
10195
The ``.env`` file of your project has been updated by the Flex recipe to
10296
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).
10498

10599
In addition, the Symfony application must bear a `JSON Web Token`_ (JWT)
106100
to the Mercure Hub to be authorized to publish updates.
107101

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.
109103

110104
The JWT must be signed with the same secret key than the one used by
111105
the Hub to verify the JWT (``aVerySecretKey`` in our example).
@@ -235,6 +229,10 @@ and to use URI Templates as patterns:
235229
* click on the request to the Mercure hub
236230
* click on the "EventStream" sub-tab.
237231

232+
.. tip::
233+
234+
Test if a URI Template match an URL using `the online debugger`_
235+
238236
Async dispatching
239237
-----------------
240238

@@ -283,8 +281,6 @@ in a ``Link`` HTTP header.
283281

284282
.. image:: /_images/mercure/discovery.png
285283

286-
*Courtesy of Mercure.rocks*
287-
288284
Symfony makes it easy to create ``Link`` headers thanks to
289285
:doc:`WebLink Component </web_link>`.
290286
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.
376372

377373
To provide this JWT, the subscriber can use a cookie,
378374
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.
380376
They are the most secure and preferred way when the client is a web browser.
381377
If the client is not a web browser, then using an authorization header is the way to go.
382378

@@ -543,9 +539,9 @@ hypermedia API, and automatic update broadcasting through the Mercure hub:
543539
public $status;
544540
}
545541
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.
549545

550546
Checkout `the dedicated API Platform documentation`_ to learn more about
551547
its Mercure support.
@@ -554,6 +550,7 @@ its Mercure support.
554550
.. _`Server-Sent Events (SSE)`: https://developer.mozilla.org/fr/docs/Server-sent_events
555551
.. _`a polyfill`: https://github.com/Yaffle/EventSource
556552
.. _`high-level implementations`: https://github.com/dunglas/mercure#resources
553+
.. _`In this recording`: https://www.youtube.com/watch?v=UI1l0JOjLeI
557554
.. _`API Platform`: https://api-platform.com
558555
.. _`Mercure.rocks`: https://mercure.rocks
559556
.. _`API Platform distribution`: https://api-platform.com/docs/distribution/
@@ -562,3 +559,4 @@ its Mercure support.
562559
.. _`IRI`: https://tools.ietf.org/html/rfc3987
563560
.. _`practical UI`: https://twitter.com/chromedevtools/status/562324683194785792
564561
.. _`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

Comments
 (0)