func newMountHandler(logger lager.Logger, client volman.Manager) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { logger := logger.Session("mount") logger.Info("start") defer logger.Info("end") body, err := ioutil.ReadAll(req.Body) if err != nil { respondWithError(logger, "Error reading mount request body", err, w) return } var mountRequest volman.MountRequest if err = json.Unmarshal(body, &mountRequest); err != nil { respondWithError(logger, fmt.Sprintf("Error reading mount request body: %#v", body), err, w) return } mountPoint, err := client.Mount(logger, mountRequest.DriverId, mountRequest.VolumeId, mountRequest.Config) if err != nil { respondWithError(logger, fmt.Sprintf("Error mounting volume %s with driver %s", mountRequest.VolumeId, mountRequest.DriverId), err, w) return } cf_http_handlers.WriteJSONResponse(w, http.StatusOK, mountPoint) } }