A Go package for building V2 Cloud Foundry Service Brokers.
- Go 1.7+
- lager
- gorilla/mux
brokerapi
defines a ServiceBroker
interface. Pass an implementation of this to brokerapi.New
, which returns an http.Handler
that you can use to serve handle HTTP requests.
Alternatively, if you already have a *mux.Router
that you want to attach service broker routes to, you can use brokerapi.AttachRoutes
.
brokerapi
defines a handful of error types in service_broker.go
for some common error cases that your service broker may encounter. Return these from your ServiceBroker
methods where appropriate, and brokerapi
will do the "right thing" (โข), and give Cloud Foundry an appropriate status code, as per the Service Broker API specification.
NewFailureResponse()
allows you to return a custom error from any of the ServiceBroker
interface methods which return an error. Within this you must define an error, a HTTP response status code and a logging key. You can also use the NewFailureResponseBuilder()
to add a custom Error:
value in the response, or indicate that the broker should return an empty response rather than the error message.
You can see the cf-redis service broker uses the BrokerAPI package to create a service broker for Redis.