Project Setup
The bookmarks API starting point — a health check endpoint and nothing else.
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
mux := http.NewServeMux()
mux.HandleFunc("GET /health", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
})
fmt.Printf("listening on :%s\n", port)
log.Fatal(http.ListenAndServe(":"+port, mux))
}go mod init bookmarks
go run .
# visit http://localhost:8080/health