mirror of
https://github.com/gofiber/fiber.git
synced 2025-04-27 13:14:31 +00:00
Merge pull request #77 from Fenny/master
Add optional offset arg to Subdomains
This commit is contained in:
commit
66856d473b
2
.github/readme2.md
vendored
2
.github/readme2.md
vendored
@ -1,6 +1,6 @@
|
||||
<img height="160px" src="https://github.com/gofiber/docs/blob/master/static/logo_320px_trans.png" alt="Fiber logo" />
|
||||
|
||||
# 🚀 Fiber <a href="README_RU.md"><img width="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ru.svg" alt="ru"/></a> <a href="README_CH.md"><img width="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ch.svg" alt="ch"/></a>
|
||||
# 🚀 Fiber <a href="https://github.com/gofiber/fiber/blob/master/.github/readme_ru.md"><img width="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ru.svg" alt="ru"/></a> <a href="https://github.com/gofiber/fiber/blob/master/.github/readme_ch.md"><img width="20px" src="https://github.com/gofiber/docs/blob/master/static/flags/ch.svg" alt="ch"/></a>
|
||||
|
||||
[](https://github.com/gofiber/fiber/releases)  [](https://godoc.org/github.com/gofiber/fiber)  [](https://github.com/gofiber/fiber/blob/master/LICENSE) [](https://gitter.im/gofiber/community)
|
||||
|
||||
|
@ -390,9 +390,13 @@ func (ctx *Ctx) Stale() bool {
|
||||
}
|
||||
|
||||
// Subdomains : https://gofiber.github.io/fiber/#/context?id=subdomains
|
||||
func (ctx *Ctx) Subdomains() (subs []string) {
|
||||
func (ctx *Ctx) Subdomains(offset ...int) (subs []string) {
|
||||
o := 2
|
||||
if len(offset) > 0 {
|
||||
o = offset[0]
|
||||
}
|
||||
subs = strings.Split(ctx.Hostname(), ".")
|
||||
subs = subs[:len(subs)-2]
|
||||
subs = subs[:len(subs)-o]
|
||||
return subs
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user