Support Let’s Encrypt

Example for 1-line LetsEncrypt HTTPS servers.

  1. package main
  2. import (
  3. "log"
  4. "github.com/iris-gonic/autotls"
  5. "github.com/kataras/iris/v12"
  6. )
  7. func main() {
  8. app := iris.Default()
  9. // Ping handler
  10. app.Get("/ping", func(ctx iris.Context) {
  11. ctx.WriteString("pong")
  12. })
  13. app.Run(iris.AutoTLS(":443", "example.com example2.com", "mail@example.com"))
  14. }

Example for custom TLS (you can bind an autocert manager too):

  1. app.Run(
  2. iris.TLS(":443", "", "", func(su *iris.Supervisor) {
  3. su.Server.TLSConfig = &tls.Config{
  4. /* your custom fields */
  5. },
  6. }),
  7. )

All iris.Runner methods such as: Addr, TLS, AutoTLS, Server, Listener and e.t.c accept a variadic input argument of func(*iris.Supervisor) to configure the http server instance on build state.