trying to compile example code from acme/autocert package with go version OS X go1.9.2 darwin/amd64 and getting: m.HTTPHandler undefined (type *autocert.Manager has no field or method HTTPHandler)
I’m missing something obvious I’m sure? Code below will not compile for me. If I comment out the groutine ( line 17 or so ) I see two methods I expect but miss the HTTPHandler method…
package main
import (
"crypto/tls"
"fmt"
"net/http"
"reflect"
"golang.org/x/crypto/acme/autocert"
)
func main() {
m := &autocert.Manager{
Cache: autocert.DirCache("secret-dir"),
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("example.org"),
}
go http.ListenAndServe(":http", m.HTTPHandler(nil))
s := &http.Server{
Addr: ":https",
TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
}
s.ListenAndServeTLS("", "")
// debug: list all method names of type = *autocert.Manager
r := reflect.TypeOf(&autocert.Manager{})
for i := 0; i < r.NumMethod(); i++ {
fmt.Println(r.Method(i).Name)
}
// prints GetCertificate Listener; yes but expected HTTPHandler also?
}