{"repo":"3n21c0/simple-go-server","free":true,"listed":false,"github":"https://github.com/3n21c0/simple-go-server","clone":"git clone https://github.com/3n21c0/simple-go-server.git","description":"A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies","language":"Go","stars":169,"topics":["logging","tracing","health-check","graceful-shutdown","golang"],"license":"MIT","category":"analytics","readme_excerpt":"simple-go-server A minimal, production-ready HTTP web server written in pure Go — using only the standard library (zero external dependencies). It demonstrates best practices for building simple web services by wiring together graceful shutdown, request tracing, structured logging, security headers, rate limiting, and panic recovery into a compact, readable server. This repository originates from this gist (by the same author), which was featured on Hacker News. Contributions are welcome, but the goal is to keep the code as simple as possible and use only the Go standard library. --- Features - Graceful shutdown — handles SIGINT / SIGTERM , drains in-flight requests (30s timeout), and flips the health flag to unhealthy before stopping. - Request ID tracking — generates a cryptographically random X-Request-Id (or propagates one you supply), truncates overly long values, and echoes it in the response. - Structured request logging — one line per request with request ID, method, path, remote address, user agent, status code, response size, and duration. - Security headers — X-Content-Type-Options , X-Frame-Options , X-XSS-Protection , Referrer-Policy , and Content-Security-Policy on every response. - Rate limiting — simple token-bucket limiter (default 100 req/s) that returns 429 Too Many Requests when the bucket is empty. - Panic recovery — any panic in a handler is recovered, logged, and returned as 500 , keeping the server alive. - Request body size limit — bodies are capped a","default_branch":null,"files":null,"tree":[],"storefront":"/r/3n21c0","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/3n21c0/simple-go-server/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}