func (c *Controller) Catalog(w http.ResponseWriter, r *http.Request) { fmt.Println("Get Service Broker Catalog...") statusCode, err := authentication(r) if err != nil { w.WriteHeader(statusCode) return } apiVersion := r.Header.Get(X_BROKER_API_VERSION_NAME) supported := validateApiVersion(apiVersion, X_BROKER_API_VERSION) if !supported { fmt.Printf("API Version is %s, not supported.\n", apiVersion) w.WriteHeader(http.StatusPreconditionFailed) return } fmt.Println("API Version is " + apiVersion) var catalog model.Catalog err = utils.ReadAndUnmarshal(&catalog, conf.CatalogPath, "catalog.json") if err != nil { w.WriteHeader(http.StatusInternalServerError) return } utils.WriteResponse(w, http.StatusOK, catalog) }
func loadServiceBindings() map[string]*model.ServiceBinding { var bindingMap map[string]*model.ServiceBinding err := utils.ReadAndUnmarshal(&bindingMap, conf.DataPath, conf.ServiceBindingsFileName) if err != nil && os.IsNotExist(err) { fmt.Printf("WARNING: key map data file '%s' does not exist: \n", conf.ServiceBindingsFileName) bindingMap = make(map[string]*model.ServiceBinding) } return bindingMap }
// private methods func loadServiceInstances() map[string]*model.ServiceInstance { var serviceInstancesMap map[string]*model.ServiceInstance err := utils.ReadAndUnmarshal(&serviceInstancesMap, conf.DataPath, conf.ServiceInstancesFileName) if err != nil && os.IsNotExist(err) { fmt.Printf("WARNING: service instance data file '%s' does not exist: \n", conf.ServiceInstancesFileName) serviceInstancesMap = make(map[string]*model.ServiceInstance) } return serviceInstancesMap }