A demonstration server for "The Absence of Errors Double Fallacy" article, showcasing various error handling fallacies and custom HTTP methods.
📖 Read the full article: https://andrey-roshchupkin.github.io/portfolio/post/the-absence-of-errors
- Go 1.25+ installed
- SQLite3 (for database operations)
-
Clone the repository
git clone <repository-url> cd strange-errors-server
-
Install dependencies
go mod tidy
-
Run the server
go run main.go
Or build and run:
go build -o strange-errors-server main.go ./strange-errors-server
-
Server will start on
http://localhost:3000 -
View API Documentation at
http://localhost:3000/swagger/ -
Stop the server
Press
Ctrl+Cin the terminal where the server is running, or if running in background:# Find and kill the process by port lsof -ti:3000 | xargs kill -9 # Or find by process name ps aux | grep "go run main.go" | grep -v grep | awk '{print $2}' | xargs kill -9 # Or if you built the binary ps aux | grep "strange-errors-server" | grep -v grep | awk '{print $2}' | xargs kill -9
The project follows Go best practices with a clean, modular structure:
strange-errors-server/
├── main.go # Entry point
├── internal/ # Private packages
│ ├── config/ # Configuration management
│ ├── database/ # Database operations
│ ├── handlers/ # HTTP handlers
│ ├── middleware/ # HTTP middleware
│ └── models/ # Data models
├── docs/ # Generated Swagger documentation
└── go.mod # Dependencies
This structure provides:
- Separation of Concerns: Each package has a single responsibility
- Testability: Easy to unit test individual components
- Maintainability: Changes to one area don't affect others
- Go Idioms: Follows standard Go project layout conventions
GET /api/articles- Get all articlesPOST /api/article- Create a new articleDELETE /api/article/{id}- Delete an article by IDPOST /api/user- Create a new userGET /api/health-check- Regular health checkGOAT /api/health-check- Custom method (try it!)GET /swagger/- Interactive API documentation
This server demonstrates various HTTP error handling patterns and custom implementations. Explore the endpoints to discover what's happening and what might be "wrong" with the responses!
This is a demonstration project for educational purposes. Feel free to fork and experiment with different error handling patterns.