예제 #1
0
func (handler *FactoryHandler) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	factories, _ := handler.Factories.All()

	response, err := puaro.BuildResponse(factories)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		fmt.Fprint(w, err)
		return
	}

	fmt.Fprint(w, response)
}
예제 #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)
}