Skip to content

Commit

Permalink
Add schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Nov 1, 2018
1 parent 1127dcc commit a9f532b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
Mercure is a protocol allowing to push data updates to web browsers and other HTTP clients in a convenient, fast, reliable and battery-efficient way.
It is especially useful to publish real-time updates of resources served through web APIs, to reactive web and mobile apps.

![Subscriptions Schema](spec/subscriptions.png)

The protocol has been published as [an Internet Draft](https://datatracker.ietf.org/doc/draft-dunglas-mercure/) that [is maintained in this repository](spec/mercure.md).

A reference, production-grade, implementation of **a Mercure hub** (the server) is also available here.
Expand Down Expand Up @@ -68,6 +70,8 @@ fetch('https://example.com/books/1') // Has this header `Link: <https://example.
});
```

![Discovery Schema](spec/discovery.png)

To dispatch an update, the publisher (an application server, a web browser...) just need to send a `POST` HTTP request to the hub.
Example using [Node.js](https://nodejs.org/) / [Serverless](https://serverless.com/):

Expand Down Expand Up @@ -277,4 +281,5 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).

## Credits

Created by [Kévin Dunglas](https://dunglas.fr). Sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop).
Created by [Kévin Dunglas](https://dunglas.fr). Schemas by [Laury Sorriaux](https://github.com/ginifizz).
Sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop).
Binary file added spec/discovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions spec/mercure.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The keywords **MUST**, **MUST NOT**, **REQUIRED**, **SHALL**, **SHALL NOT**, **S

# Discovery

![Discovery Schema](discovery.png)

If the publisher is a server, it **SHOULD** advertise the URL of one or more hubs to the subscriber, allowing it to receive live updates when topics are updated.
If more than one hub URL is specified, it is expected that the publisher notifies each hub, so the subscriber **MAY** subscribe to one or more of them.

Expand Down Expand Up @@ -81,6 +83,8 @@ Note: the discovery mechanism described in this section [is strongly inspired fr

# Subscriptions

![Subscriptions Schema](subscriptions.png)

The subscriber subscribes to an URL exposed by a hub to receive updates of one or many topics.
To subscribe to updates, the client opens an HTTPS connection following the [Server-Sent Events specification](https://html.spec.whatwg.org/multipage/server-sent-events.html) to the hub's subscription URL advertised
by the Publisher. The `GET` HTTP method must be used.
Expand Down
Binary file added spec/subscriptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a9f532b

Please sign in to comment.