This is a simple Golang echo server that listens for HTTP requests and echoes back the exact request received, including the HTTP protocol, headers, and body.
- Echoes back the exact HTTP request received
- Logs incoming requests and dumped request details
- Containerized using Docker for easy deployment
- Go (version 1.22 or later)
- Docker (for containerized deployment)
- Clone the repository:
git clone https://github.com/ibihim/echo-server- Change into the project directory:
cd echo-server- Run the server:
go run main.goThe server will start running on http://localhost:8080.
- Send HTTP requests to the server using tools like cURL or a web browser.
Example cURL command:
curl -X POST -H "Content-Type: text/plain" \
-H "Authorization: Bearer fake-token" \
-d "hello world" http://localhost:8080The server will echo back the exact request received.
To deploy the echo server using Docker, follow these steps:
- Build the Docker image:
docker build -t echo-server .- Run the Docker container:
docker run -p 8080:8080 echo-serverThe server will start running inside the container and will be accessible on http://localhost:8080.
To run the unit tests for the echo server, use the following command:
go testThe tests will make a request to the server and verify that the response body contains the expected content based on the request.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.