th5/_dev/caddy/echo.go
2017-09-05 21:06:35 +01:00

26 lines
402 B
Go

package main
import (
"fmt"
"html"
"log"
"net/http"
"os"
)
var htmlBody = []byte(`
<!DOCTYPE html>
<p>Hello!
<code><pre>
`)
func main() {
http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
rw.Write(htmlBody)
for name, value := range r.Header {
fmt.Fprintf(rw, "%s: %s\n", name, html.EscapeString(value[0]))
}
})
log.Println(http.ListenAndServe(os.Args[1], nil))
}