Skip to content

Commit

Permalink
export config BE http request handler for transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir20 committed Mar 13, 2024
1 parent 88137be commit d3e3529
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions testhelper/docker/resource/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (c *config) setBackendConfigURL(url string) {
// })
func WithUserTransformations(transformations map[string]string, cleaner resource.Cleaner) func(*config) {
return func(conf *config) {
backendConfigSvc := NewTestBackendConfigServer(transformations)
backendConfigSvc := newTestBackendConfigServer(transformations)

conf.setBackendConfigURL(dockerTestHelper.ToInternalDockerHost(backendConfigSvc.URL))
conf.extraHosts = append(conf.extraHosts, "host.docker.internal:host-gateway")
Expand All @@ -78,7 +78,7 @@ func WithConnectionToHostEnabled() func(*config) {
// WithConfigBackendURL should not be used with WithUserTransformations option
func WithConfigBackendURL(url string) func(*config) {
return func(conf *config) {
conf.setBackendConfigURL(url)
conf.setBackendConfigURL(dockerTestHelper.ToInternalDockerHost(url))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ const (
versionIDKey = "versionId"
)

func NewTestBackendConfigServer(transformations map[string]string) *kithttptest.Server {
func newTestBackendConfigServer(transformations map[string]string) *kithttptest.Server {
return kithttptest.NewServer(NewTransformerBackendConfigHandler(transformations))
}

// NewTransformerBackendConfigHandler returns http request handler to handle all backend config requests by transformer
func NewTransformerBackendConfigHandler(transformations map[string]string) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc(getByVersionIdEndPoint, getByVersionIdHandler(transformations))
return kithttptest.NewServer(mux)
return mux
}

func getByVersionIdHandler(transformations map[string]string) func(http.ResponseWriter, *http.Request) {
Expand Down

0 comments on commit d3e3529

Please sign in to comment.