Skip to content

Commit

Permalink
Fix not responding api after remove gorilla mux by go http (#714)
Browse files Browse the repository at this point in the history
Fix not responding api after remove gorilla mux by go http
  • Loading branch information
ukff authored and kyma-gopher-bot committed Aug 22, 2024
1 parent 85cdcf9 commit 90871c1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func NewAPI(serviceManager *servicemanager.Client, secretProvider *clusterobject
}

func (a *API) Start() {
mux := http.ServeMux{}
mux := http.NewServeMux()
mux.HandleFunc("GET /api/secrets", a.ListSecrets)
mux.HandleFunc("GET /api/service-instances", a.ListServiceInstances)
mux.HandleFunc("PUT /api/service-instance/{id}", a.CreateServiceInstance)
mux.HandleFunc("GET /api/service-instance/{id}", a.GetServiceInstance)
mux.HandleFunc("GET /api/service-offerings/{namespace}/{name}", a.ListServiceOfferings)
mux.HandleFunc("GET /api/service-offering/{id}", a.GetServiceOffering)
go func() {
err := http.ListenAndServe(":3006", nil)
err := http.ListenAndServe(":3006", mux)
if err != nil {
a.slogger.Error("failed to Start listening", "error", err)
}
Expand All @@ -46,8 +46,8 @@ func (a *API) CreateServiceInstance(writer http.ResponseWriter, request *http.Re

func (a *API) ListServiceOfferings(writer http.ResponseWriter, request *http.Request) {
a.setupCors(writer, request)
namespace := request.URL.Query().Get("namespace")
name := request.URL.Query().Get("name")
namespace := request.PathValue("namespace")
name := request.PathValue("name")
err := a.serviceManager.SetForGivenSecret(context.Background(), name, namespace)
if returnError(writer, err) {
return
Expand Down

0 comments on commit 90871c1

Please sign in to comment.