All Projects â†’ mjc-gh â†’ Esper

mjc-gh / Esper

📻 Event Source powered by hyper written in Rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Esper

Piping Server Rust
Infinitely transfer between any device over pure HTTP, designed for everyone using Unix pipe and even for browser users
Stars: ✭ 88 (+104.65%)
Mutual labels:  hyper, http-server
Restbed
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
Stars: ✭ 1,551 (+3506.98%)
Mutual labels:  server-sent-events, http-server
go-sse
Fully featured, spec-compliant HTML5 server-sent events library
Stars: ✭ 165 (+283.72%)
Mutual labels:  http-server, server-sent-events
Fs2 Http
Http Server and client using fs2
Stars: ✭ 132 (+206.98%)
Mutual labels:  server-sent-events, http-server
aitch
aitch is a simple, lightweight toolkit for building HTTP servers in Rust, loosely based on Go's net/http.
Stars: ✭ 19 (-55.81%)
Mutual labels:  hyper, http-server
Na
Share files on your local network
Stars: ✭ 15 (-65.12%)
Mutual labels:  http-server
Fastdeploy
Deploy DL/ ML inference pipelines with minimal extra code.
Stars: ✭ 35 (-18.6%)
Mutual labels:  http-server
Markdownshare
The code behind https://markdownshare.com/
Stars: ✭ 15 (-65.12%)
Mutual labels:  http-server
Swarmmskit
Provisioning a Full MS NanoServer Cluster Swarm on Hyper-V with Consul + Vault + Private Registry + Management UI for your cluster Swarm Docker (all these tools will be configure during the deployment) ... all VMs integrated in an Active Directory Domain or using a Local account. You can use (means configure the FW rules for you !) or disable it ...
Stars: ✭ 13 (-69.77%)
Mutual labels:  hyper
Hyper
An HTTP library for Rust
Stars: ✭ 8,912 (+20625.58%)
Mutual labels:  hyper
Jiny
Lightweight, modern, simple JVM web framework for rapid development in the API era
Stars: ✭ 40 (-6.98%)
Mutual labels:  http-server
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-30.23%)
Mutual labels:  http-server
Hyperbeast
Supreme Terminal prompt
Stars: ✭ 20 (-53.49%)
Mutual labels:  hyper
Http File Server
tiny portable HTTP file server. single binary, no dependencies. linux, osx, windows. #golang
Stars: ✭ 37 (-13.95%)
Mutual labels:  http-server
Hyper Match
HyperTerm extension which matches regular expressions with predefined commands
Stars: ✭ 15 (-65.12%)
Mutual labels:  hyper
Updog
Updog is a replacement for Python's SimpleHTTPServer. It allows uploading and downloading via HTTP/S, can set ad hoc SSL certificates and use http basic auth.
Stars: ✭ 994 (+2211.63%)
Mutual labels:  http-server
Pwndrop
Self-deployable file hosting service for red teamers, allowing to easily upload and share payloads over HTTP and WebDAV.
Stars: ✭ 878 (+1941.86%)
Mutual labels:  http-server
Fht2p
A cross-platform HTTP static file server developed using Rust.
Stars: ✭ 28 (-34.88%)
Mutual labels:  http-server
Nodemcu Espress
Ultra-Lightweight and modular Node.js express like http server for NodeMCU. web - ESP8266
Stars: ✭ 39 (-9.3%)
Mutual labels:  http-server
Liberator
An Elixir library for building RESTful applications.
Stars: ✭ 28 (-34.88%)
Mutual labels:  http-server

esper

Esper is a standalone Event Source / Server Sent Events (SSE) broker. It is powered by the most excellent event driven hyper library.

Usage

There are two main routes provided by esper; one for subscribing and one for publishing:

  • GET /subscribe/:topic_id

    • When requested with a valid topic_id, this route will respond with the Event Source content type and will leave the connection open. The client is now subscribed for the given topic_id and will receive all published messages for this topic.
  • POST /publish/:topic_id

    • When requested with a valid topic_id, this route will publish a message to all subscribed clients. The entire POST body is considered to be the message payload. Thus, the POST data should be formatted like a server-sent event and include a data field with an optional event and id field.

The :topic_id is specified as the second part of the request path. This ID must be alphanumeric characters only (case insensitive) and must be between 8 and 64 characters in length. Further validation may be introduced at a later time.

Authentication

Esper uses JSON Web Tokens to ensure requests are legitimate. For tokens to be considered valid, they must include an exp field set to some future timestamp (in seconds as an integer) as well as a sub field set to the topic_id.

Authentication is available for both the subscribe and publish routes and is enabled by setting one or both environmental variables. These variables are named ESPER_SUBSCRIBER_SECRET and ESPER_PUBLISHER_SECRET. It is possible to enable just one kind of authentication by leaving the other secret undefined.

Also, please note that, the /stats route is protected by JWT using the publisher secret since this route is intended for developer use.

Examples

Here is a quick example of what to expect from esper using curl. First, we subscribe a client to the topic abcdef123:

curl -v -X GET http://localhost:3000/subscribe/abcdef123
> GET /subscribe/abcdef123 HTTP/1.1
> Host: localhost:3001
>
< HTTP/1.1 200 OK
< Content-Type: text/event-stream
< Date: Mon, 11 Jul 2016 20:27:53 GMT
< Transfer-Encoding: chunked
<

Next, using another shell, lets publish a message with curl to the same topic:

curl -v -X POST http://localhost:3000/publish/abcdef123 -d $'event:
testing\ndata: {some:"data"}'
> POST /publish/abcdef123 HTTP/1.1
> Host: localhost:3001
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded

Now if we go back to the first subscribed curl client, we will see the following output:

event: testing
data: {"some":"data"}

We can also subscribe using the EventSource object in the browser. In fact, esper is mainly designed for this use case!

A quick example use some JavaScript would be as follows:

var evtSource = new EventSource('localhost:3000/subscribe/abcdef123');

evtSource.onmessage = function(evt) {
    console.log(evt.data);
};

There you have it, the essence of esper!

Building

Esper can be built with stable Rust and the cargo command-line tool

git clone https://github.com/mikeycgto/esper.git && cd esper
cargo build --release 

Deploying

Esper ships as a standalone executable with a small set of command-line options. Here is esper's help screen for more details on the supported options:

$ esper --help
esper - Event Source HTTP server, powered by hyper.

Usage:
  esper [--bind=<bind>] [--port=<port>] [--threads=<st>]
  esper (-h | --help)
  esper --version

Options:
  -h --help          Show this screen.
  --version          Show version.
  -b --bind=<bind>   Bind to specific IP [default: 127.0.0.1]
  -p --port=<port>   Run on a specific port number [default: 3000]
  -t --threads=<st>  Number of server threads [default: 2].
  --no-auth          Run without JWT authentication.

Docker

Esper can run in docker container

Create docker image and build

git clone https://github.com/mikeycgto/esper.git && cd esper
docker build -t unique-image-name .

Run in interactive mode (twice CTRL+C for exit)

docker run -it -p 3000:3000 unique-image-name

Run in background (Daemon)

# First launch
docker run -d --name esper_server_name -p 3000:3000

# Stop
docker stop esper_server_name

# Start
docker start esper_server_name
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].