From 0b4438ec824ea0f2e129ce4c1099f10f0f1f121a Mon Sep 17 00:00:00 2001 From: Ewan Jones Date: Tue, 5 Mar 2019 09:05:42 +0900 Subject: [PATCH] Using context utility functions to add found service and plan instances to request context --- api.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 93c728b9..f47ae8f4 100644 --- a/api.go +++ b/api.go @@ -19,10 +19,11 @@ import ( "encoding/json" "errors" "fmt" - "github.com/pivotal-cf/brokerapi/middlewares/originating_identity_header" "net/http" "strconv" + "github.com/pivotal-cf/brokerapi/middlewares/originating_identity_header" + "code.cloudfoundry.org/lager" "github.com/gorilla/mux" "github.com/pivotal-cf/brokerapi/auth" @@ -183,6 +184,7 @@ func (h serviceBrokerHandler) provision(w http.ResponseWriter, req *http.Request services, _ := h.serviceBroker.Services(req.Context()) for _, service := range services { if service.ID == details.ServiceID { + req = req.WithContext(AddServiceToContext(req.Context(), &service)) valid = true break } @@ -199,6 +201,7 @@ func (h serviceBrokerHandler) provision(w http.ResponseWriter, req *http.Request for _, service := range services { for _, plan := range service.Plans { if plan.ID == details.PlanID { + req = req.WithContext(AddServicePlanToContext(req.Context(), &plan)) valid = true break } @@ -797,4 +800,4 @@ func checkBrokerAPIVersionHdr(req *http.Request) (brokerVersion, error) { return version, errors.New("X-Broker-API-Version Header must be 2.x") } return version, nil -} \ No newline at end of file +}