dejankos / http-echo

Caching http push/poll server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Http Echo Server

Build Status

Caching http echo server for push/poll requests on some path.

Usage

http-echo 0.1.0

USAGE:
    http-echo [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -i, --ip <ip>              Server ip [default: 127.0.0.1]
    -p, --port <port>          Server port [default: 8080]
    -t, --ttl <ttl>            Cache TTL [default: 900000]
    -w, --workers <workers>    Server workers - default value is number of logical CPUs

Push

http://localhost:8080/push/CUSTOM_PATH

Example:

> curl -d '{ "name": "value" }' -H 'Content-Type: application/json' http://localhost:8080/push/example/next?a=1&b=2

> {
    "http_version": "HTTP/1.1",
    "method": "POST",
    "headers": {
      "user-agent": "curl/7.68.0",
      "content-type": "application/json",
      "accept": "*/*",
      "content-length": "19",
      "host": "localhost:8080"
    },
    "query_string": "a=1",
    "path": "/example/next",
    "body": "{ \"name\": \"value\" }",
    "time": 1596271868195,
    "ip": "127.0.0.1:41992"
  }

Multiple requests can be cached on the same path.

Poll

http://localhost:8080/poll/CUSTOM_PATH

Cached requests can be polled only once:

Example:

> curl http://localhost:8080/poll/example/next

> [
    {
      "http_version": "HTTP/1.1",
      "method": "POST",
      "headers": {
        "user-agent": "curl/7.68.0",
        "content-type": "application/json",
        "accept": "*/*",
        "content-length": "19",
        "host": "localhost:8080"
      },
      "query_string": "a=1",
      "path": "/example/next",
      "body": "{ \"name\": \"value\" }",
      "time": 1596271868195,
      "ip": "127.0.0.1:41992"
    }
  ]

License

Http Echo Server is licensed under the Apache License, Version 2.0

About

Caching http push/poll server

License:Apache License 2.0


Languages

Language:Rust 100.0%