Skip to content

Instantly share code, notes, and snippets.

@mattes
Created Feb 12, 2021
Embed
What would you like to do?
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