Skip to content

Commit

Permalink
ingest: support for multiple data domains
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Dec 19, 2023
1 parent 95bc257 commit 6d3429d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ingest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func patchEvent(c *gin.Context, event *AnalyticsServerEvent, tp string, ingestTy
}

func (r *Router) getDataLocator(c *gin.Context, event *AnalyticsServerEvent, ingestType IngestType) (cred StreamCredentials, err error) {
dataHost := r.config.DataDomain
dataHosts := strings.Split(r.config.DataDomain, ",")
cred.IngestType = ingestType
if c.GetHeader("Authorization") != "" {
wk := strings.Replace(c.GetHeader("Authorization"), "Basic ", "", 1)
Expand All @@ -519,11 +519,14 @@ func (r *Router) getDataLocator(c *gin.Context, event *AnalyticsServerEvent, ing
cred.WriteKey = c.GetHeader("X-Write-Key")
}
host := strings.Split(c.Request.Host, ":")[0]
if dataHost != "" && strings.HasSuffix(host, "."+dataHost) {
cred.Slug = strings.TrimSuffix(host, "."+dataHost)
} else {
cred.Domain = host
for _, dataHost := range dataHosts {
if dataHost != "" && strings.HasSuffix(host, "."+dataHost) {
cred.Slug = strings.TrimSuffix(host, "."+dataHost)
return
}
}
cred.Domain = host

return
}
func isInternalHeader(headerName string) bool {
Expand Down

0 comments on commit 6d3429d

Please sign in to comment.