package main import ( "fmt" "net/http" ) type reqExampleHandler int func (hello reqExampleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Only GET requests are allowed", http.StatusMethodNotAllowed) return } fmt.Println("Method:", r.Method) fmt.Println("URL:", r.URL.String()) fmt.Println("Host:", r.Host) fmt.Println("Accept-Header", r.Header.Get("Accept")) queryParams := r.URL.Query() fmt.Println("Query Parameters:") for key, values := range queryParams { for _, value := range values { fmt.Printf(" %s = %s\n", key, value) } } w.Write([]byte("

GET: http.Request-Beispiel

")) } func main() { var r reqExampleHandler http.ListenAndServe("localhost:8080", r) }