1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

Wildcard subdomain full support | v3.0.0-beta.2

Update to v3.0.0-beta.2.
Wildcard subdomain e-book section:
https://kataras.gitbooks.io/iris/content/subdomains.html
This commit is contained in:
Makis Maropoulos
2016-06-04 16:20:32 +03:00
parent b4612dcfe0
commit 1a433e34d5
9 changed files with 93 additions and 24 deletions

View File

@@ -95,6 +95,20 @@ func (ctx *Context) PostFormValue(name string) string {
return string(ctx.RequestCtx.PostArgs().Peek(name))
}
// GetSubdomain returns the subdomain if any, else empty string
func (ctx *Context) GetSubdomain() string {
if ctx.subdomain == "" {
host := ctx.HostString()
if index := strings.IndexByte(host, '.'); index > 0 {
subdomain := host[0:index]
ctx.subdomain = subdomain
}
}
return ctx.subdomain
}
// URLEncode returns the path encoded as url
// useful when you want to pass something to a database and be valid to retrieve it via context.Param
// use it only for special cases, when the default behavior doesn't suits you.