82 lines
2.1 KiB
Markdown
82 lines
2.1 KiB
Markdown
# 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
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone https://github.com/yourusername/playground-go.git
|
|
cd playground-go
|
|
```
|
|
|
|
2. Run the server:
|
|
```bash
|
|
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:
|
|
|
|
1. Fork the repository
|
|
2. Create a new branch for your feature
|
|
3. Submit a pull request with a clear description of your changes
|