Skip to content

Commit

Permalink
Using context utility functions to add found service and plan instanc…
Browse files Browse the repository at this point in the history
…es to request context
  • Loading branch information
kisamoto committed Mar 5, 2019
1 parent ae39d64 commit 0b4438e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
}

0 comments on commit 0b4438e

Please sign in to comment.