drnic / brokerapi

A go package for the V2 CF Service Broker API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

brokerapi

Build Status

A Go package for building V2 Open Service Broker API compliant Service Brokers.

Dependencies

We use dep to manager our dependencies. Use dep ensure in order to download the required packages.

Usage

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.

Error types

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.

Custom Errors

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.

Example Service Broker

You can see the cf-redis service broker uses the BrokerAPI package to create a service broker for Redis.

About

A go package for the V2 CF Service Broker API

License:Apache License 2.0


Languages

Language:Go 100.0%