Documentation
¶
Overview ¶
Package autotls support Let's Encrypt for a Go server application.
package main
import (
"log"
"github.com/gin-gonic/autotls"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
// Ping handler
r.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ReadHeaderTimeout = 3 * time.Second
ReadHeaderTimeout is the maximum duration for reading the headers of the request.
Functions ¶
func Run ¶
Run starts an HTTPS server with automatic Let's Encrypt certificate management and HTTP to HTTPS redirection. The server runs until interrupted and shuts down gracefully.
func RunWithContext ¶ added in v0.0.5
RunWithContext starts an HTTPS server with automatic Let's Encrypt certificate management, HTTP-to-HTTPS redirection, and graceful shutdown. The provided context controls server lifetime.
func RunWithManager ¶
RunWithManager starts an HTTPS server using a custom autocert.Manager for certificate administration. Useful for advanced autocert settings; includes HTTP to HTTPS redirection.
func RunWithManagerAndTLSConfig ¶ added in v0.0.4
RunWithManagerAndTLSConfig starts an HTTPS server using a custom autocert.Manager and custom tls.Config, with HTTP to HTTPS redirection. Allows advanced TLS and certificate settings. r - HTTP handler for HTTPS requests m - autocert.Manager, manages certificate issuance and renewal tlsc - Custom TLS configuration to control various certificate and protocol settings
Types ¶
This section is empty.