From ec4270c43f1ddd37d1eb19da5db78129b93f72b7 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Thu, 4 May 2017 22:36:53 +0200 Subject: add "cli" package with a Query method --- .../x/crypto/acme/autocert/example_test.go | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 vendor/golang.org/x/crypto/acme/autocert/example_test.go (limited to 'vendor/golang.org/x/crypto/acme/autocert/example_test.go') diff --git a/vendor/golang.org/x/crypto/acme/autocert/example_test.go b/vendor/golang.org/x/crypto/acme/autocert/example_test.go new file mode 100644 index 0000000..c6267b8 --- /dev/null +++ b/vendor/golang.org/x/crypto/acme/autocert/example_test.go @@ -0,0 +1,34 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package autocert_test + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + + "golang.org/x/crypto/acme/autocert" +) + +func ExampleNewListener() { + mux := http.NewServeMux() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, TLS user! Your config: %+v", r.TLS) + }) + log.Fatal(http.Serve(autocert.NewListener("example.com"), mux)) +} + +func ExampleManager() { + m := autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist("example.org"), + } + s := &http.Server{ + Addr: ":https", + TLSConfig: &tls.Config{GetCertificate: m.GetCertificate}, + } + s.ListenAndServeTLS("", "") +} -- cgit v1.3.1