1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +00:00

General Improvements (UseRouter per Party, fix AutoTLS). Read HISTORY.md

relative to: https://github.com/kataras/iris/issues/1577 and https://github.com/kataras/iris/issues/1578
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-12 07:20:07 +03:00
parent da029d6f37
commit 0761bc35ee
15 changed files with 639 additions and 120 deletions

37
iris.go
View File

@@ -589,10 +589,39 @@ func Addr(addr string, hostConfigs ...host.Configurator) Runner {
}
}
// TLSNoRedirect is a `host.Configurator` which can be passed as last argument
// to the `TLS` and `AutoTLS` functions. It disables the automatic
// registration of redirection from "http://" to "https://" requests.
var TLSNoRedirect = func(su *host.Supervisor) { su.NoRedirect() }
var (
// TLSNoRedirect is a `host.Configurator` which can be passed as last argument
// to the `TLS` runner function. It disables the automatic
// registration of redirection from "http://" to "https://" requests.
// Applies only to the `TLS` runner.
// See `AutoTLSNoRedirect` to register a custom fallback server for `AutoTLS` runner.
TLSNoRedirect = func(su *host.Supervisor) { su.NoRedirect() }
// AutoTLSNoRedirect is a `host.Configurator`.
// It registers a fallback HTTP/1.1 server for the `AutoTLS` one.
// The function accepts the letsencrypt wrapper and it
// should return a valid instance of http.Server which its handler should be the result
// of the "acmeHandler" wrapper.
// Usage:
// getServer := func(acme func(http.Handler) http.Handler) *http.Server {
// srv := &http.Server{Handler: acme(yourCustomHandler), ...otherOptions}
// go srv.ListenAndServe()
// return srv
// }
// app.Run(iris.AutoTLS(":443", "example.com example2.com", "mail@example.com", getServer))
//
// Note that if Server.Handler is nil then the server is automatically ran
// by the framework and the handler set to automatic redirection, it's still
// a valid option when the caller wants just to customize the server's fields (except Addr).
// With this host configurator the caller can customize the server
// that letsencrypt relies to perform the challenge.
// LetsEncrypt Certification Manager relies on http://%s:80/.well-known/acme-challenge/<TOKEN>.
AutoTLSNoRedirect = func(getFallbackServer func(acmeHandler func(fallback http.Handler) http.Handler) *http.Server) host.Configurator {
return func(su *host.Supervisor) {
su.NoRedirect()
su.Fallback = getFallbackServer
}
}
)
// TLS can be used as an argument for the `Run` method.
// It will start the Application's secure server.