A simple server for mirroring HTTP requests for testing.
Go to file
Dorian 01063534ec
continuous-integration/drone/push Build is failing Details
Fix Docker build issue.
2024-02-24 12:38:29 -05:00
src Finish documenting the codebase. 2024-02-24 12:34:19 -05:00
.dockerignore Add a Dockerfile and initial DroneCI configuration. 2024-02-21 23:17:17 -05:00
.drone.yml Bump the version for a new minor release. 2024-02-24 12:35:53 -05:00
.gitignore Migrate to using axum over actix for web framework. 2024-02-06 15:51:30 -05:00
Cargo.toml Bump the version for a new minor release. 2024-02-24 12:35:53 -05:00
Dockerfile Fix Docker build issue. 2024-02-24 12:38:29 -05:00
LICENSE Wire up project for working with actix. 2023-01-12 09:41:47 -05:00
README.md Bump the version for a new minor release. 2024-02-24 12:35:53 -05:00
publish-deb.sh Update README and improve publishing script. 2024-02-23 14:29:48 -05:00

README.md

mirror-server

A simple server for mirroring HTTP requests for testing. It is optimized for working with REST API JSON calls, and catching headers.

Build Status

Getting Started

  • Use the latest stable version of Rust using rustup.
  • Build: cargo build
  • Test: cargo test
  • Run the server: cargo run -- --port=8080
  • Create a DEB package:
    • Install cargo-deb: cargo install cargo-deb
    • Create the DEB package: cargo deb
  • Faster builds using cargo-watch: cargo watch -x run
  • Installing the binary locally from source: cargo install --path .

Install

mirror-server is installable either by a local Cargo install or a Debian package. Additionally mirror-server can be run as a Docker container using the latest (or tagged) release.

Docker Image

Run via Docker using:

$ docker run -p 8080:8080 code.birch-tree.net/dorian/mirror-server:latest

Debian Package

Download the DEB file, and install it:

VERSION=0.3.1
REPO_URL=https://code.birch-tree.net/api/packages/dorian/generic/mirror-server/
curl "${REPO_URL}/${VERSION}/mirror-server_${VERSION}_amd64.deb"
sudo dpkg -i "mirror-server-${VERSION}_amd64.deb"

Afterward you can run using mirror-server

Usage

You can get all the options that mirror-server supports by running it with the help option --help or -h:

$ mirror-server --help
A simple server for mirror HTTP requests for testing.

Usage: mirror-server [OPTIONS]

Options:
  -p, --port <PORT>  Port to run on [default: 8080]
  -i, --ips <IPS>    Listen to IP mask [default: 0.0.0.0]
  -h, --help         Print help
  -V, --version      Print version

After starting the server, you can send requests to it. Using curl you can send mirror-server JSON requests:

$ curl -s -X PUT -D '{"hello": "world"}' -H 'Content-Type: application/json' \
     http://localhost:8080/api/testing | jq .

And mirror-server responds to requests with JSON responses:

{
  "method": "PUT",
  "path": "/api/testing",
  "host": "localhost:8180",
  "headers": {
    "accept": "*/*",
    "content-length": "18",
    "content-type": "application/json",
    "host": "localhost:8080",
    "user-agent": "curl/7.68.0"
  },
  "body": {
    "hello": "world"
  }
}