A simple HTTP server — the fourth project in the go-space learning series.
go run main.goServer starts on http://localhost:8080.
curl http://localhost:8080/ # Welcome to my server
curl "http://localhost:8080/hello?name=John" # Hello John
curl http://localhost:8080/health # OKServer is listening on port 8080:
GET /
GET /hello
GET /health
net/httppackage — routing and server setup- Handler functions (
http.ResponseWriter,*http.Request) - Writing responses with
fmt.Fprintlnandfmt.Fprintf - Reading query parameters with
r.URL.Query().Get() - Inspecting requests via
r.Methodandr.URL.Path - Middleware pattern — wrapping handlers for cross-cutting concerns