This is a simple, barebones HTTP/1.1 server built with Go. It's capable of handling multiple clients simultaneously and serves as a basic example of building web servers in Go.
- Concurrent Connections: Handles multiple clients at once using Goroutines.
- Basic Routing: Includes a simple router to handle different URL paths.
- Static & Dynamic Responses: Serves both static content and dynamically generated responses based on the request.
- Go (version 1.18 or later)
-
Clone the repository:
git clone https://github.com/your-username/go-http-server.git cd go-http-server -
Run the server:
./run.sh
The server will start on localhost:4221.
The server exposes the following endpoints:
GET /: Returns a simple "Hello, World!" message.GET /echo/{message}: Echoes back the{message}provided in the URL path.
.
├── app/
│ ├── main.go # Main application entry point
│ ├── request.go # Request parsing logic
│ ├── response.go # Response building logic
│ └── router.go # Routing logic
├── go.mod
├── go.sum
├── run.sh # Script to run the server
└── README.md
- Go: The server is built entirely using the standard Go library, with no external frameworks.