Created
February 12, 2021 07:59
-
-
Save mattes/1891c7e8d235a11b3cdedb8977f69a83 to your computer and use it in GitHub Desktop.
Quick HTTPS debug server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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