36 lines
666 B
Go
36 lines
666 B
Go
package controllers
|
|
|
|
import (
|
|
"github.com/gorilla/mux"
|
|
"github.com/unrolled/render"
|
|
"moretcgshop/app/models"
|
|
"net/http"
|
|
)
|
|
|
|
func (server *Server) Categories(w http.ResponseWriter, r *http.Request) {
|
|
renderer := render.New(render.Options{
|
|
Layout: "layout",
|
|
Extensions: []string{".html", ".tmpl"},
|
|
})
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
if vars["id"] == "" {
|
|
return
|
|
}
|
|
|
|
categorieModel := models.Category{}
|
|
|
|
categorien, err := categorieModel.GetCategorie(server.DB, vars["id"])
|
|
|
|
if err != nil {
|
|
println(err.Error())
|
|
return
|
|
}
|
|
|
|
_ = renderer.HTML(w, http.StatusOK, "categories", map[string]interface{}{
|
|
//"user": user,
|
|
"categorien": categorien,
|
|
})
|
|
}
|