Esempio n. 1
0
func (handler *ClusterHandler) Register(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	puaro.HTTPLogger(r)

	err := joinCluster(handler.FactoryName, handler.ClusterAddress)
	if err != nil {
		fmt.Fprint(w, err)
		return
	}

	w.WriteHeader(200)
}
Esempio n. 2
0
func (handler *DatasetHandler) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	puaro.HTTPLogger(r)

	storage := handler.Storage
	datasets := storage.Datasets()

	res, err := puaro.BuildResponse(datasets)
	if err != nil {
		w.WriteHeader(400)
		fmt.Fprint(w, err)
		return
	}

	fmt.Fprint(w, res)
}
Esempio n. 3
0
func (handler *DatasetHandler) Create(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	puaro.HTTPLogger(r)

	storage := handler.Storage
	dataset := storage.NewDataset("")

	unmarshaller.IoReader(r.Body, dataset)

	err := storage.Insert(dataset)
	if err != nil {
		w.WriteHeader(400)
		fmt.Fprint(w, err)
		return
	}

	w.WriteHeader(200)
}
Esempio n. 4
0
func (handler *JobHandler) Create(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	puaro.HTTPLogger(r)
	cluster := handler.Cluster

	job := &models.Job{}
	if err := unmarshaller.IoReader(r.Body, job); err != nil {
		w.WriteHeader(400)
		fmt.Fprint(w, err)
		return
	}

	if err := cluster.AddJob(job); err != nil {
		w.WriteHeader(400)
		fmt.Fprint(w, err)
		return
	}

	w.WriteHeader(200)
}