Exemplo n.º 1
0
func CategoryGetTree(w http.ResponseWriter, r *http.Request) {
	categoryController := controller.Category{}
	categories, err := categoryController.GetCategoryTree(r, 0)

	if err != nil {
		log.Println(err)
	} else {
		jsonRes, _ := json.Marshal(categories)
		fmt.Fprint(w, string(jsonRes))
	}
}
Exemplo n.º 2
0
func CategoryCreateHandler(w http.ResponseWriter, r *http.Request) {
	categoryController := controller.Category{}

	//verify user is admin
	adminAuth := auth.Auth{}
	status := adminAuth.VerifyAdmin(r)

	if status == true {

		_, err := categoryController.CreateCategory(r)

		if err != nil {
			log.Println(err)
		} else {
			fmt.Fprint(w, true)
		}
	}
}