This looked manageable at first glance and then I actually read the full requirements.
Start by clarifying requirements and constraints (language, libraries, concurrency model) to show you think before coding. Then walk through a layered architecture: socket handling, HTTP parsing, routing, and response generation, highlighting trade-offs at each layer. Finish with testing, error handling, and operational concerns like graceful shutdown and structured logging.
Pro tip: Emphasize that you'd use the standard library's HTTP server as a reference but implement your own to demonstrate understanding of the protocol; mention that you'd avoid premature optimization and focus on correctness first, then concurrency and timeouts.
Ask about language preference, allowed dependencies, expected load, and whether HTTP/1.1 keep-alive is required. Confirm the scope of 'from scratch' (e.g., can you use standard library sockets?).
Outline components: a TCP listener, a connection handler with timeouts, an HTTP parser, a router, and handlers for /health, /echo, and static files. Discuss concurrency model (thread-per-connection vs. event loop) and trade-offs.
Describe parsing request line, headers, and body (for POST). Explain routing logic, status codes (400, 404, 405), and response formatting with correct Content-Type headers.
Cover request timeouts (read/write deadlines), graceful shutdown (signal handling, closing listener, waiting for active connections), and structured logging (e.g., JSON with method, path, status, duration).
Propose unit tests for parser, router, and handlers; integration tests using a test client. Include instructions to run locally (e.g., go run main.go --port 8080) and example curl commands.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.