th5/_dev/caddy/echo.go

26 lines
402 B
Go
Raw Normal View History

2017-03-08 15:44:37 +00:00
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))
}