示例#1
0
// HandlerDelete represents a API handler to delete an article
func HandlerDelete(req *router.Request) {
	//appCtx := app.GetContext()
	//doc := appCtx.DB.C("article")
	//article := Article{
	//	ID:        bson.NewObjectId(),
	//	CreatedAt: time.Now(),
	//}
	//
	//if err := gin.Bind(&article); err != nil {
	//	req.BadRequest(err)
	//	return
	//}
	//
	//if err := doc.Insert(article); err != nil {
	//	if mgo.IsDup(err) {
	//		req.Conflict("The slug %s already exists in the database", article.Slug)
	//		return
	//	}
	//
	//	req.ServerError(err)
	//	return
	//}

	//httpResponse.Ok(gin, httpResponse.Resource{article})
	req.NoContent()
}
示例#2
0
// HandlerGet represents a API handler to get a single article
func HandlerGet(req *router.Request) {
	// appCtx := app.GetContext()
	// doc := appCtx.DB.C("article")
	// article := article.Article{}
	// id := bson.ObjectIdHex(mux.Vars(req.Request)["id"])

	// if err := doc.Find(bson.M{"_id": id}).One(&article); err != nil {
	// 	if err == mgo.ErrNotFound {
	// 		req.NotFound("Article %s not found", id)
	// 		return
	// 	}
	// 	req.Error(NewSer)
	// 	return
	// }

	//httpResponse.Ok(gin, httpResponse.Resource{article})
	req.NoContent()
}