-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (34 loc) · 1.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"net/http"
"os"
"code.cloudfoundry.org/lager"
"github.com/pivotal-cf/brokerapi"
"github.com/rscale-training/simple-service-broker/broker"
)
func statusAPI(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "OK")
}
func main() {
logger := lager.NewLogger("simple-broker")
logger.RegisterSink(lager.NewWriterSink(os.Stdout, lager.INFO))
logger.RegisterSink(lager.NewWriterSink(os.Stderr, lager.ERROR))
servicebroker := &broker.SimpleBroker{
Instances: map[string]brokerapi.GetInstanceDetailsSpec{},
Bindings: map[string]brokerapi.GetBindingSpec{},
}
brokerCredentials := brokerapi.BrokerCredentials{
Username: "admin",
Password: "secret",
}
brokerAPI := brokerapi.New(servicebroker, logger, brokerCredentials)
http.HandleFunc("/health", statusAPI)
http.Handle("/", brokerAPI)
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
fmt.Println("\n\nStarting Simple Service Broker on 0.0.0.0:" + port)
logger.Fatal("http-listen", http.ListenAndServe("0.0.0.0:"+port, nil))
}