This commit is contained in:
Fred Boniface
2025-12-05 16:30:34 +00:00
commit c6efed07f5
6 changed files with 112 additions and 0 deletions

28
src/main.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"fmt"
"log"
"net/http"
)
func echoHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s %s\n", r.Method, r.URL.String())
fmt.Fprintln(w, "Headers:")
for name, values := range r.Header {
for _, value := range values {
fmt.Fprintf(w, "%s: %s\n", name, value)
}
}
fmt.Fprintln(w, "\nBody:")
r.Body.Close()
}
func main() {
http.HandleFunc("/", echoHandler)
port := "8080"
log.Printf("Starting echo server on port %s...\n", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}