forked from jmalloc/echo-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a127ec3
commit 2e983a9
Showing
1 changed file
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
# Echo Server | ||
# Static Response Server | ||
|
||
A very simple HTTP echo server with support for web-sockets. | ||
A very simple static HTTP server with support for web-sockets. | ||
|
||
- Any messages sent from a web-socket client are echoed. | ||
- Any request, independent of content, will always return a static body and content type. | ||
- Any message sent from a web-socket client will be replied with same static response. | ||
- Visit `/.ws` for a basic UI to connect and send web-socket messages. | ||
- Requests to any other URL will return the request headers and body. | ||
- The `CONTENT_TYPE` and `CONTENT_BODY` defines response's content type and body. | ||
- The `PORT` environment variable sets the server port. | ||
- No TLS support yet :( | ||
|
||
To run as a container: | ||
|
||
``` | ||
docker run --detach -P jmalloc/echo-server | ||
docker run --env CONTENT_TYPE=application/json \ | ||
--env CONTENT_BODY='{"upstream": "production"}' \ | ||
--detach -P pagarme/static-response-server | ||
``` | ||
|
||
To run as a service: | ||
Also works great with `docker-compose`: | ||
|
||
``` | ||
docker service create --publish 8080 jmalloc/echo-server | ||
```yaml | ||
services: | ||
production: | ||
image: pagarme/static-response-server | ||
environment: | ||
- PORT=8080 | ||
- CONTENT_TYPE=application/json | ||
- CONTENT_BODY={"upstream":"production"} | ||
ports: | ||
- "8080:8080" | ||
|
||
sandbox: | ||
image: pagarme/static-response-server | ||
environment: | ||
- PORT=8081 | ||
- CONTENT_TYPE=application/json | ||
- CONTENT_BODY={"upstream":"sandbox"} | ||
ports: | ||
- "8081:8081" | ||
``` |