https://github.com/ndrean/sse
Produce ServerSentEvents in Elixir
https://github.com/ndrean/sse
elixir https sse
Last synced: 10 months ago
JSON representation
Produce ServerSentEvents in Elixir
- Host: GitHub
- URL: https://github.com/ndrean/sse
- Owner: ndrean
- Created: 2022-07-24T19:55:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-31T17:08:35.000Z (over 3 years ago)
- Last Synced: 2025-02-06T06:46:07.702Z (11 months ago)
- Topics: elixir, https, sse
- Language: Elixir
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sse
The Elixir code tests works only in HTTP mode, but `curl` works for both.
To change mode, select in "Application" between the two setups:
```elixir
#Application
{Plug.Cowboy, scheme: :https, plug: SSE.Router, options: plug_options},
{Plug.Cowboy, scheme: :http,...}
```
In `Router`, you have to declare the client endpoints for CORS.
Client side, you have to select also the endpoint whether HTTP or HTTPS (in .ENV)
The Docker image works locally on HTTPS. It needs some modifications to be able to deploy.
For HTTP/1.1 between and , run:
```bash
PORT 4000 mix run --no-halt
```
For TLS HTTP/2, between self-signed and , run:
```bash
PORT=4000 mix run --no-halt
```
Used `mkcert` for self-signed certificats
```bash
# run this one
curl -v https://localhost:4043/sse
# then run this one
curl -X POST -H "content-type: application/json" -d '{"test": "hello Amy"}' https://localhost:4043/post
```
Caddy is ready.