RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests. It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router) Note: this method will block the calling goroutine indefinitely unless an error happens.
(addr, certFile, keyFile string)
| 559 | // It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router) |
| 560 | // Note: this method will block the calling goroutine indefinitely unless an error happens. |
| 561 | func (engine *Engine) RunTLS(addr, certFile, keyFile string) (err error) { |
| 562 | debugPrint("Listening and serving HTTPS on %s\n", addr) |
| 563 | defer func() { debugPrintError(err) }() |
| 564 | |
| 565 | if engine.isUnsafeTrustedProxies() { |
| 566 | debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + |
| 567 | "Please check https://github.com/gin-gonic/gin/blob/master/docs/doc.md#dont-trust-all-proxies for details.") |
| 568 | } |
| 569 | |
| 570 | server := &http.Server{ // #nosec G112 |
| 571 | Addr: addr, |
| 572 | Handler: engine.Handler(), |
| 573 | } |
| 574 | err = server.ListenAndServeTLS(certFile, keyFile) |
| 575 | return |
| 576 | } |
| 577 | |
| 578 | // RunUnix attaches the router to a http.Server and starts listening and serving HTTP requests |
| 579 | // through the specified unix socket (i.e. a file). |