An HTTP server is a program that listens on a network address (host:port) and serves HTTP requests by calling a handler.
In Go, the standard library package `net/http` provides everything you need to build a basic server.
package main import ( "log" "net/http" ) func main() { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello")) }) mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("ok")) }) log.Println("listening on :8080") log.Fatal(http.ListenAndServe(":8080", mux)) }
For production, you often use `http.Server` to set timeouts and graceful shutdown.
Example fields: