...

Source file src/github.com/launchdarkly/go-server-sdk/v6/testhelpers/ldservices/events_service.go

Documentation: github.com/launchdarkly/go-server-sdk/v6/testhelpers/ldservices

     1  package ldservices
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/launchdarkly/go-test-helpers/v3/httphelpers"
     7  )
     8  
     9  const (
    10  	serverSideEventsPath           = "/bulk"
    11  	serverSideDiagnosticEventsPath = "/diagnostic"
    12  )
    13  
    14  // ServerSideEventsServiceHandler creates an HTTP handler to mimic the LaunchDarkly server-side events service.
    15  // It returns a 202 status for POSTs to the /bulk and /diagnostic paths, otherwise a 404.
    16  func ServerSideEventsServiceHandler() http.Handler {
    17  	return httphelpers.HandlerForPath(
    18  		serverSideEventsPath,
    19  		httphelpers.HandlerForMethod("POST", httphelpers.HandlerWithStatus(202), nil),
    20  		httphelpers.HandlerForPath(
    21  			serverSideDiagnosticEventsPath,
    22  			httphelpers.HandlerForMethod("POST", httphelpers.HandlerWithStatus(202), nil),
    23  			nil,
    24  		),
    25  	)
    26  }
    27  

View as plain text