Skip to content

A simple HTTP server that echoes back request information.

License

Notifications You must be signed in to change notification settings

rellyson/http-echo

Repository files navigation

echo-logo

HTTP Echo

A simple HTTP server that echoes back request information.

license go gh-stars docker-pulls

This project is a simple HTTP server that echoes back request information. It is useful for testing and debugging deployments and networking configurations by providing a simple interface to inspect requests.

Features

The HTTP Echo server provides the following features:

  • Accepts HTTP methods GET, POST, PUT, PATCH and DELETE.
  • Echoes back request information in json format:
    • host: hostname and ip
    • headers: request headers
    • queries: query parameters
    • params: path parameters
    • body: request body
  • Returns a custom status code for a request (provided via query).
    • E.g. http://127.0.0.1:3000/?status=404 returns a 404 response code.
  • Exports metrics in prometheus format for monitoring.

Usage

The server accepts the following parameters:

  • -listen: the address to listen on (default: :3000)
  • -metrics: the path to expose metrics on (default: /metrics)

Running the server

You can run the server using via the following methods:

Local using go

Yuu can run the server locally using the following command:

# execute via go run
$ go run cmd/server/main.go

# or build and execute
$ go build -o htt-echo cmd/server/main.go
$ ./http-echo

Docker

There is also a docker image available on Docker Hub.

# run using docker
$ docker run -p 3000:3000 rellyson/http-echo:latest

License

This project is licensed under the MIT License - see the LICENSE file for details.