server.go
package main
import (
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /health", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNoContent)
})
mux.HandleFunc("GET /accounts/{id}", func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Verified-Account-ID") != r.PathValue("id") {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
_, _ = w.Write([]byte("account ready\n"))
})
log.Fatal(http.ListenAndServe(":8080", mux))
}