5
0
Fork 0
backend-subscribe/README.md

48 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2019-02-10 04:29:56 +08:00
# backend-subscribe
Client subscribe counterpart to backend-publish. Subscribe to receive the results of your requests to backend-publish in some weird extended streaming async HTTP-ish thing. Refer to ```backend-store```.
2019-02-16 00:16:53 +08:00
2019-02-24 04:03:07 +08:00
**To run this service securely means to run it behind traefik forwarding auth to `backend-auth`**
2019-02-18 23:44:02 +08:00
## Environment Variables
Supply environment variables by either exporting them or editing ```.env```.
| ENV | Description | Default |
| ---- | ----------- | ------- |
| LISTEN | Host and port number to listen on | :8080 |
| NATS | Host and port of nats | nats://localhost:4222 |
2019-02-16 00:16:53 +08:00
## API
```
2019-02-24 04:03:07 +08:00
GET /subscribe
2019-02-16 00:16:53 +08:00
```
Subscribe to your SSE stream.
2019-02-24 04:03:07 +08:00
### Required headers
2019-02-16 00:16:53 +08:00
2019-02-24 04:03:07 +08:00
| Name | Description |
| ---- | ----------- |
| X-User-Claim | Stringified user claim, populated by `backend-auth` called by `traefik` |
2019-02-16 00:16:53 +08:00
### Success Response (200 OK)
An [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) stream.
### Event
```
{
"code": <http status code>
"message": <message>
}
```
2019-02-24 04:03:07 +08:00
#### Errors
| Code | Description |
| ---- | ----------- |
| 400 | Invalid user claims header. |