gorilla/mux

I would like to know how I could use Mux for TSL configuration and handle https requests

Leon16 opened this issue · 2 comments

I would like to know how I could use Mux for TSL configuration and handle https requests. Should I just implement the following to achieve it:

r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)

server := &http.Server{
Addr: ":" + *port,
ReadTimeout: 5 * time.Minute,
WriteTimeout: 10 * time.Second,
TLSConfig: &tls.Config{ServerName: *host},
Handler: r,

}

if err := server.ListenAndServeTLS(*srvCert, *srvKey); err != nil {
log.Fatal(err)
}

Where the paths to *host, *port, *sevCert and *srvKey will be provided via command line call

Not sure this would work.

Syntax is correct and it should work. For taking input from CLI, you need to write additional code using either os.Args, flag or a package like cobra.

@Leon16 can we close this issue? if there are no further questions or doubts?