func Add(article models.Article, r render.Render, db *mgo.Database) { fmt.Println(article) err := db.C("articles").Insert(article) if err != nil { r.HTML(400, "400", err) } else { r.Redirect("/") } }
func List(r render.Render, params martini.Params, db *mgo.Database) { var articles []models.Article err := db.C("articles").Find(nil).All(&articles) if err != nil { r.Error(400) } r.HTML(200, "articles/list", articles) }
func Show(params martini.Params, r render.Render, db *mgo.Database) { article := models.Article{} oId := bson.ObjectIdHex(params["_id"]) err := db.C("articles").FindId(oId).One(&article) if err != nil { r.HTML(400, "400", err) } r.HTML(200, "articles/show", article) }
func AddEdit(r render.Render) { r.HTML(200, "articles/form", nil) }