Subdomains

An array 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. c.Subdomains(offset ...int) []string
  1. // Host: "tobi.ferrets.example.com"
  2.  
  3. app.Get("/", func(c *fiber.Ctx) {
  4. c.Subdomains() // ["ferrets", "tobi"]
  5. c.Subdomains(1) // ["tobi"]
  6. })