Skip to content

Instantly share code, notes, and snippets.

@mattes
Created February 12, 2021 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattes/1891c7e8d235a11b3cdedb8977f69a83 to your computer and use it in GitHub Desktop.
Save mattes/1891c7e8d235a11b3cdedb8977f69a83 to your computer and use it in GitHub Desktop.
Quick HTTPS debug server
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"os"
"golang.org/x/crypto/acme/autocert"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
req, err := httputil.DumpRequest(r, true)
if err != nil {
w.WriteHeader(500)
return
}
fmt.Fprintln(os.Stdout, string(req)+"\n\n")
w.WriteHeader(200)
})
log.Fatal(http.Serve(autocert.NewListener("my-domain.com"), mux))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment