main.go 469 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "log"
  6. "log/slog"
  7. "net/http"
  8. )
  9. var (
  10. bind = flag.String("bind", ":3923", "TCP port to bind to")
  11. )
  12. func main() {
  13. flag.Parse()
  14. slog.Info("listening", "url", "http://localhost"+*bind)
  15. log.Fatal(http.ListenAndServe(*bind, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  16. slog.Info("got request", "method", r.Method, "path", r.RequestURI)
  17. fmt.Fprintln(w, r.Method, r.RequestURI)
  18. r.Header.Write(w)
  19. })))
  20. }