Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Leon16 opened this issue Nov 17, 2022 · 2 comments
Labels

Comments

@Leon16
Copy link

Leon16 commented Nov 17, 2022

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.

@amustaque97
Copy link
Contributor

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.

@amustaque97
Copy link
Contributor

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

@coreydaley coreydaley changed the title [question] I would like to know how I could use Mux for TSL configuration and handle https requests Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants