Example #1
0
// createRemoveHandler returns the handler that removes blob a single blob at path
func createRemoveHandler(storage blobserver.Storage) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
		res, err := handleRemove(r, storage)
		if err != nil {
			httputil.ServeJSONError(rw, err)
		} else {
			httputil.ReturnJSON(rw, res)
		}
	})
}
Example #2
0
func createStatHandler(storage blobserver.BlobStatter) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		req.ParseForm()
		vars := mux.Vars(req)
		res, err := handleStat(req, storage, []string{vars["blobRef"]})

		if err != nil {
			httputil.ServeJSONError(rw, err)
		} else {
			httputil.ReturnJSON(rw, res)
		}
	})
}
Example #3
0
func createBatchStatHandler(storage blobserver.BlobStatter) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		req.ParseForm()
		blobs, _ := req.Form["blob"]
		res, err := handleStat(req, storage, blobs)

		if err != nil {
			httputil.ServeJSONError(rw, err)
		} else {
			httputil.ReturnJSON(rw, res)
		}
	})
}
Example #4
0
func handleConfig(w http.ResponseWriter, req *http.Request, storage blobserver.StorageConfiger) {
	res := new(protocol.ConfigResponse)
	res.Data = storage.Config()
	log.Println("config:", res)
	httputil.ReturnJSON(w, res)
}