Project
my-http-server
shippedHTTP parsed by hand over raw TCP, to stop treating net/http as magic.
go · tcp
What it is
A custom-built HTTP server written in Go, created as a learning project to understand how HTTP works under the hood. It explores the core functionality of an HTTP server, such as handling requests, managing routes and building responses manually, without relying on high-level frameworks.
Architecture
Everything lives in two files:
myhttp/myhttp.go: the core server logic and routing. It definesHttpRequest(method, URI, version, headers and body),HttpResponse(status line, headers and body), theHandleFunchandler type and aServerwithHandleFunction(method, path, handler),Serve(req)andHttpServer(address).main.go: the entry point, which defines routes and starts the server on0.0.0.0:6969.
Requests are matched to handlers by method and path. It supports GET, POST, PUT, DELETE, PATCH, OPTIONS and HEAD, middleware that wraps handlers, and handles multiple client connections with goroutines.
What I learned
What’s next
From the README’s “Future Enhancements” list:
- Cookie handling.
- Session management for user authentication.
- Common middlewares such as authentication, logging and rate limiting.
- HTTPS support over TLS.
- Robust error handling for edge cases.