Skip to content

Commit

Permalink
ingest: added /api/s/s2s/batch s2s only endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Jan 8, 2024
1 parent 8275491 commit f027674
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ingest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func NewRouter(appContext *Context) *Router {
"/projects/:writeKey/settings",
"/b",
"/batch",
"/api/s/s2s/batch",
"/api/s/:tp",
"/api/s/s2s/:tp",
})
Expand Down Expand Up @@ -118,8 +119,11 @@ func NewRouter(appContext *Context) *Router {
fast.Match([]string{"OPTIONS", "POST"}, "/v1/b", router.BatchHandler)
fast.Match([]string{"OPTIONS", "POST"}, "/batch", router.BatchHandler)
fast.Match([]string{"OPTIONS", "POST"}, "/b", router.BatchHandler)
fast.Match([]string{"OPTIONS", "POST"}, "/api/s/s2s/batch", router.BatchHandler)

fast.Match([]string{"OPTIONS", "POST"}, "/api/s/:tp", router.IngestHandler)
fast.Match([]string{"OPTIONS", "POST"}, "/api/s/s2s/:tp", router.IngestHandler)

fast.Match([]string{"GET", "HEAD", "OPTIONS"}, "/p.js", router.ScriptHandler)

engine.GET("/health", func(c *gin.Context) {
Expand Down Expand Up @@ -199,7 +203,7 @@ func patchEvent(c *gin.Context, messageId string, event *AnalyticsServerEvent, t
}
}
if !eventTypesSet.Contains(typeFixed) {
return fmt.Errorf("Unknown event type: %s", tp)
return fmt.Errorf("Unknown event type: %s", typeFixed)
}
if typeFixed == "track" {
//check event name
Expand Down
8 changes: 7 additions & 1 deletion ingest/router_batch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ func (r *Router) BatchHandler(c *gin.Context) {
rError = r.ResponseError(c, http.StatusOK, "error parsing message", false, err, true)
return
}
loc, err := r.getDataLocator(c, IngestTypeWriteKeyDefined, func() string { return payload.WriteKey })
var ingestType IngestType
if c.FullPath() == "/api/s/s2s/batch" {
ingestType = IngestTypeS2S
} else {
ingestType = IngestTypeWriteKeyDefined
}
loc, err := r.getDataLocator(c, ingestType, func() string { return payload.WriteKey })
if err != nil {
rError = r.ResponseError(c, http.StatusOK, "error processing message", false, err, true)
return
Expand Down

0 comments on commit f027674

Please sign in to comment.