1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +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

View File

@@ -740,7 +740,9 @@ func (ctx *Context) RequestPath(escape bool) string {
// return false
// } no, it will not work because map is a random peek data structure.
// Host returns the host part of the current URI.
// Host returns the host:port part of the request URI, calls the `Request().Host`.
// To get the subdomain part as well use the `Request().URL.Host` method instead.
// To get the subdomain only use the `Subdomain` method instead.
// This method makes use of the `Configuration.HostProxyHeaders` field too.
func (ctx *Context) Host() string {
for header, ok := range ctx.app.ConfigurationReadOnly().GetHostProxyHeaders() {
@@ -762,13 +764,14 @@ func GetHost(r *http.Request) string {
return host
}
// contains subdomain.
return r.URL.Host
}
// Subdomain returns the subdomain of this request, if any.
// Note that this is a fast method which does not cover all cases.
func (ctx *Context) Subdomain() (subdomain string) {
host := ctx.Host()
host := ctx.request.URL.Host // ctx.Host()
if index := strings.IndexByte(host, '.'); index > 0 {
subdomain = host[0:index]
}