Subdomains

Returns a string slice of subdomains in the domain name of the request.

The application property subdomain offset, which defaults to 2, is used for determining the beginning of the subdomain segments.

  1. func (c *Ctx) Subdomains(offset ...int) []string
  1. // Host: "tobi.ferrets.example.com"
  2. app.Get("/", func(c *fiber.Ctx) error {
  3. c.Subdomains() // ["ferrets", "tobi"]
  4. c.Subdomains(1) // ["tobi"]
  5. // ...
  6. })