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.
13 "golang.org/x/crypto/acme/autocert"
16 func ExampleNewListener() {
17 mux := http.NewServeMux()
18 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
19 fmt.Fprintf(w, "Hello, TLS user! Your config: %+v", r.TLS)
21 log.Fatal(http.Serve(autocert.NewListener("example.com"), mux))
24 func ExampleManager() {
25 m := autocert.Manager{
26 Prompt: autocert.AcceptTOS,
27 HostPolicy: autocert.HostWhitelist("example.org"),
31 TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
33 s.ListenAndServeTLS("", "")