|
1 | 1 | # brokerapi
|
2 | 2 |
|
3 |
| -[](https://travis-ci.org/pivotal-cf/brokerapi) |
| 3 | +[](https://travis-ci.org/pivotal-cf/brokerapi) |
4 | 5 |
|
5 |
| -A Go package for building [V2 Open Service Broker API](https://github.com/openservicebrokerapi/servicebroker/) compliant Service Brokers. |
| 6 | +A Go package for building [V2 Open Service Broker |
| 7 | +API](https://github.com/openservicebrokerapi/servicebroker/) compliant Service |
| 8 | +Brokers. |
6 | 9 |
|
7 | 10 | ## [Docs](https://godoc.org/github.com/pivotal-cf/brokerapi)
|
8 | 11 |
|
9 | 12 | ## Dependencies
|
10 | 13 |
|
11 | 14 | - Go 1.7+
|
12 | 15 | - [lager](https://github.com/cloudfoundry/lager)
|
13 |
| -- [gorilla/mux](https://github.com/gorilla/mux) |
| 16 | +- [gorilla/mux v1.6.1+](https://github.com/gorilla/mux) |
14 | 17 |
|
15 |
| -We use [dep](https://github.com/golang/dep) to manager our dependencies. Use `dep ensure` in order to download the required packages. |
| 18 | +We use [dep](https://github.com/golang/dep) to manager our dependencies. Use |
| 19 | +`dep ensure` in order to download the required packages. |
16 | 20 |
|
17 | 21 | ## Usage
|
18 | 22 |
|
19 |
| -`brokerapi` defines a [`ServiceBroker`](https://godoc.org/github.com/pivotal-cf/brokerapi#ServiceBroker) interface. Pass an implementation of this to [`brokerapi.New`](https://godoc.org/github.com/pivotal-cf/brokerapi#New), which returns an `http.Handler` that you can use to serve handle HTTP requests. |
| 23 | +`brokerapi` defines a |
| 24 | +[`ServiceBroker`](https://godoc.org/github.com/pivotal-cf/brokerapi#ServiceBroker) |
| 25 | +interface. Pass an implementation of this to |
| 26 | +[`brokerapi.New`](https://godoc.org/github.com/pivotal-cf/brokerapi#New), which |
| 27 | +returns an `http.Handler` that you can use to serve handle HTTP requests. |
20 | 28 |
|
21 |
| -Alternatively, if you already have a `*mux.Router` that you want to attach service broker routes to, you can use [`brokerapi.AttachRoutes`](https://godoc.org/github.com/pivotal-cf/brokerapi#AttachRoutes). |
| 29 | +Alternatively, if you already have a `*mux.Router` that you want to attach |
| 30 | +service broker routes to, you can use |
| 31 | +[`brokerapi.AttachRoutes`](https://godoc.org/github.com/pivotal-cf/brokerapi#AttachRoutes). |
| 32 | +Note in this case, the Basic Authentication and Originating Identity middleware |
| 33 | +will not be set up, so you will have to attach them manually if required. |
22 | 34 |
|
23 | 35 | ## Error types
|
24 | 36 |
|
25 |
| -`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](https://docs.cloudfoundry.org/services/api.html). |
| 37 | +`brokerapi` defines a handful of error types in `service_broker.go` for some |
| 38 | +common error cases that your service broker may encounter. Return these from |
| 39 | +your `ServiceBroker` methods where appropriate, and `brokerapi` will do the |
| 40 | +"right thing" (™), and give Cloud Foundry an appropriate status code, as per |
| 41 | +the [Service Broker API |
| 42 | +specification](https://docs.cloudfoundry.org/services/api.html). |
26 | 43 |
|
27 | 44 | ### Custom Errors
|
28 | 45 |
|
29 |
| -`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. |
| 46 | +`NewFailureResponse()` allows you to return a custom error from any of the |
| 47 | +`ServiceBroker` interface methods which return an error. Within this you must |
| 48 | +define an error, a HTTP response status code and a logging key. You can also |
| 49 | +use the `NewFailureResponseBuilder()` to add a custom `Error:` value in the |
| 50 | +response, or indicate that the broker should return an empty response rather |
| 51 | +than the error message. |
30 | 52 |
|
31 | 53 | ## Originating Identity
|
32 | 54 |
|
33 |
| -The request context for every request contains the unparsed `X-Broker-API-Originating-Identity` header under the key `originatingIdentityKey`. |
34 |
| -More details on how the Open Service Broker API manages request originating identity is available [here](https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#originating-identity). |
| 55 | +The request context for every request contains the unparsed |
| 56 | +`X-Broker-API-Originating-Identity` header under the key |
| 57 | +`originatingIdentityKey`. More details on how the Open Service Broker API |
| 58 | +manages request originating identity is available |
| 59 | +[here](https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#originating-identity). |
35 | 60 |
|
36 | 61 | ## Example Service Broker
|
37 | 62 |
|
38 |
| -You can see the [cf-redis](https://github.com/pivotal-cf/cf-redis-broker/blob/2f0e9a8ebb1012a9be74bbef2d411b0b3b60352f/broker/broker.go) service broker uses the BrokerAPI package to create a service broker for Redis. |
| 63 | +You can see the |
| 64 | +[cf-redis](https://github.com/pivotal-cf/cf-redis-broker/blob/2f0e9a8ebb1012a9be74bbef2d411b0b3b60352f/broker/broker.go) |
| 65 | +service broker uses the BrokerAPI package to create a service broker for Redis. |
0 commit comments