listener_test.go 514 B

123456789101112131415161718192021
  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package autocert_test
  5. import (
  6. "fmt"
  7. "log"
  8. "net/http"
  9. "golang.org/x/crypto/acme/autocert"
  10. )
  11. func ExampleNewListener() {
  12. mux := http.NewServeMux()
  13. mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  14. fmt.Fprintf(w, "Hello, TLS user! Your config: %+v", r.TLS)
  15. })
  16. log.Fatal(http.Serve(autocert.NewListener("example.com"), mux))
  17. }