Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

httpserver

A simple HTTP server — the fourth project in the go-space learning series.


Usage

go run main.go

Server starts on http://localhost:8080.

Routes

curl http://localhost:8080/                      # Welcome to my server
curl "http://localhost:8080/hello?name=John"     # Hello John
curl http://localhost:8080/health                # OK

Terminal logs

Server is listening on port 8080:
GET /
GET /hello
GET /health

Concepts Covered

  • net/http package — routing and server setup
  • Handler functions (http.ResponseWriter, *http.Request)
  • Writing responses with fmt.Fprintln and fmt.Fprintf
  • Reading query parameters with r.URL.Query().Get()
  • Inspecting requests via r.Method and r.URL.Path
  • Middleware pattern — wrapping handlers for cross-cutting concerns

Go Level Concepts