예제 #1
0
func (self *projectServer) Get(ctx context.Context, q *msg.ProjectQuery) (*msg.Project, error) {
	var project database.Project
	err := self.core.Db.Get("Projects", q.Id, &project)

	if err != nil {
		return nil, err
	}

	return project.ToMessage(), err
}
예제 #2
0
func (self *Server) createProject(w http.ResponseWriter, r *http.Request) {
	var project database.Project

	err := self.read(r, &project)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
	}
	project.Id = bson.NewObjectId()
	err = self.core.Db.Create(database.ProjectsCol, &project)

	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
	}

	self.respond(w, &project)

}