Skip to content

Commit

Permalink
route the API subdomain (#1910)
Browse files Browse the repository at this point in the history
Co-authored-by: Asim Aslam <asim@aslam.me>
  • Loading branch information
ben-toogood and asim committed Aug 7, 2020
1 parent 324c4e6 commit ac1aace
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/resolver/subdomain/subdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func (r *Resolver) Domain(req *http.Request) string {
// remove the domain from the host, leaving the subdomain, e.g. "staging.foo.myapp.com" => "staging.foo"
subdomain := strings.TrimSuffix(host, "."+domain)

// ignore the API subdomain
if subdomain == "api" {
return ""
}

// return the reversed subdomain as the namespace, e.g. "staging.foo" => "foo-staging"
comps := strings.Split(subdomain, ".")
for i := len(comps)/2 - 1; i >= 0; i-- {
Expand Down

0 comments on commit ac1aace

Please sign in to comment.