https://github.com/sgchris/grecho
Echo servers are invaluable tools for testing and debugging. In my case I used it for testing my web client that I created for a specific project. There are many echo servers out there, but Grecho gives you full control over the response that you get, with the possibility to override every part of it.
🔍 What is Grecho?
Grecho is an asynchronous HTTP echo server written in Rust. It listens for incoming HTTP requests and responds with the same body, headers, and URI, making it an excellent tool for testing HTTP clients, proxies, and other networked applications.
⚙️ Key Features
Echo Request Body: Returns the exact body of the incoming request, or the overridden value provided in the headers.
Echo Request Headers: Reflects all headers from the request, excluding internal headers and the Host header.
Set a custom HTTP status code using the internal.status-code header.
Define a custom response body with the internal.response-body header.
Asynchronous Performance: Built with Rust's async features, ensuring high performance and scalability.
🛠️ Use Cases
Grecho is versatile and can be used in various scenarios:
Testing HTTP Clients: Simulate server responses to test how your client handles different scenarios. That was the purpose in my case.
Debugging Proxies: Ensure that proxies correctly forward and receive requests.
Learning Tool: Understand HTTP request and response structures by observing the echoed data.
Benchmarking: Evaluate the performance of HTTP clients and servers under controlled conditions.
📦 Installation & Usage
Prerequisites
- Rust (version 1.60 or higher)
- Cargo (Rust's package manager)
- GitHub
Steps
# git clone https://github.com/sgchris/grecho.git
# cd grecho
# cargo build --release
# cargo run -- --host 127.0.0.1 --port 3000
By default, the server binds to 127.0.0.1:3000. You can specify a custom host and port using the --host and --port flags, respectively.
📬 Request Examples
Requests examples using Curl
A simple request
# curl http://127.0.0.1:3000/hello
Override the response status code:
# curl -H "internal.status-code: 404" http://127.0.0.1:3000/hello
Override the response body:
# curl -H "internal.response-body: Custom Response" http://127.0.0.1:3000/hello
📌 Conclusion
Grecho is a powerful yet simple tool for anyone working with HTTP. Its lightweight design and Rust's performance make it an excellent choice for developers looking to test and debug their applications. Whether you're building a client, proxy, or server, Grecho can help ensure that your HTTP interactions are functioning as expected.
For more information and to get started, visit the Grecho GitHub repository.
Top comments (0)