Initial
This commit is contained in:
28
src/main.go
Normal file
28
src/main.go
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user