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.
r: HTTP handler for HTTPS requests. domain: One or more domain names for certificate issuance.
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 support. The provided context controls the server's lifetime and shutdown.
ctx: Context for graceful shutdown. r: HTTP handler for HTTPS requests. domain: One or more domain names for certificate issuance.
func RunWithManager ¶
RunWithManager starts an HTTPS server using a custom autocert.Manager for certificate management, with HTTP-to-HTTPS redirection. Useful for advanced autocert configuration.
r: HTTP handler for HTTPS requests. m: Custom autocert.Manager instance.
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.
r: HTTP handler for HTTPS requests. m: Custom autocert.Manager instance. tlsc: Custom TLS configuration.
Types ¶
This section is empty.