No description
handlers | ||
internal/config | ||
logger | ||
middleware | ||
static | ||
.gitignore | ||
go.mod | ||
main.go | ||
README.md |
Playground GO
A modern web server implementation in Go that demonstrates production-ready HTTP server concepts.
Overview
This project implements a robust HTTP server that:
- Listens on a configurable port
- Handles HTTP requests with a custom router
- Processes requests concurrently using goroutines
- Implements middleware for logging and request processing
- Provides graceful shutdown capabilities
- Uses structured logging
- Follows clean architecture principles
Project Structure
.
├── main.go # Application entry point
├── handlers/ # HTTP request handlers
├── middleware/ # HTTP middleware components
├── logger/ # Structured logging implementation
├── internal/ # Internal packages and configuration
├── static/ # Static file serving
├── go.mod # Go module definition
├── .gitignore # Git ignore rules
└── README.md # This file
Prerequisites
- Go 1.16 or higher
Usage
- Clone the repository:
git clone https://github.com/yourusername/playground-go.git
cd playground-go
- Run the server:
go run main.go
The server will start on the configured port (default: 7878).
Features
- Concurrent request handling using goroutines
- Graceful server shutdown
- Structured logging
- Middleware support for request processing
- Configuration management
- Clean architecture with separated concerns
- Static file serving
- Error handling and logging
Configuration
The server can be configured through environment variables:
PORT
: The port number to listen on (default: 7878)- Additional configuration options can be added in the
internal/config
package
Error Handling
The server includes comprehensive error handling for:
- Server startup and shutdown
- Request processing
- Configuration loading
- Graceful shutdown with timeout
- Structured error logging
Contributing
Feel free to submit issues and enhancement requests! When contributing, please:
- Fork the repository
- Create a new branch for your feature
- Submit a pull request with a clear description of your changes