예제 #1
0
func (s *Server) deleteItemSchemaByCollectionName(t *transaction.Transaction) {
	collectionName := t.Params["collectionName"]
	err := s.DB.DeleteItemSchemaByCollectionName(collectionName)
	if err != nil {
		t.WriteError(err)
		return
	}

	t.NoResultWithStatusCode(http.StatusNoContent)
}
예제 #2
0
func (s *Server) findItemSchemaByCollectionName(t *transaction.Transaction) {
	collectionName := t.Params["collectionName"]
	itemSchema, err := s.DB.FindItemSchemaByCollectionName(collectionName)
	if err != nil {
		t.WriteError(err)
		return
	}
	itemSchema.AttachDefaultLinks(t.BaseUrl())
	t.WriteResult(itemSchema)
}
예제 #3
0
파일: server.go 프로젝트: ricobl/beat
func (s *Server) findItemSchemaByCollectionName(t *transaction.Transaction) {
	collectionName := t.Params["collectionName"]
	itemSchema, err := s.DB.FindItemSchemaByCollectionName(collectionName)
	if err != nil {
		t.WriteError(err)
		return
	}

	t.WriteResult(itemSchema)
}
예제 #4
0
func (s *Server) findCollectionSchemaByCollectionName(t *transaction.Transaction) {
	collectionName := t.Params["collectionName"]
	itemSchema, err := s.DB.FindItemSchemaByCollectionName(collectionName)

	if err == db.ItemSchemaNotFound {
		t.WriteError(db.CollectionSchemaNotFound)
		return
	} else if err != nil {
		t.WriteError(err)
		return
	}
	collectionSchema := schemas.NewCollectionSchema(itemSchema)
	collectionSchema.ApplyBaseUrl(t.BaseUrl())

	t.WriteResult(collectionSchema)
}
예제 #5
0
파일: server.go 프로젝트: ricobl/beat
func (s *Server) findItemSchema(t *transaction.Transaction) {
	filter, err := db.NewFilterFromQueryString(t.Req.URL.RawQuery)

	if err != nil {
		t.WriteError(errors.Wraps(err, 400))
		return
	}

	reply, findErr := s.DB.FindItemSchema(filter)
	if findErr != nil {
		t.WriteError(findErr)
		return
	}

	t.WriteResult(reply)
}
예제 #6
0
func (s *Server) findOneItemSchema(t *transaction.Transaction) {
	filter, err := db.NewFilterFromQueryString(t.Req.URL.RawQuery)

	if err != nil {
		t.WriteError(errors.Wraps(err, 400))
		return
	}

	itemSchema, findErr := s.DB.FindOneItemSchema(filter)
	if findErr != nil {
		t.WriteError(findErr)
		return
	}

	itemSchema.AttachDefaultLinks(t.BaseUrl())
	t.WriteResult(itemSchema)
}
예제 #7
0
파일: server.go 프로젝트: ricobl/beat
func (s *Server) createItemSchema(t *transaction.Transaction) {
	itemSchema, err := schemas.NewItemSchemaFromReader(t.Req.Body)

	if err != nil {
		t.WriteError(err)
		return
	}

	err = s.DB.CreateItemSchema(itemSchema)

	if err != nil {
		t.WriteError(err)
		return
	}

	t.WriteResultWithStatusCode(http.StatusCreated, itemSchema)
}
예제 #8
0
func (s *Server) createItemSchema(t *transaction.Transaction) {
	itemSchema, err := schemas.NewItemSchemaFromReader(t.Req.Body)

	if err != nil {
		t.WriteError(err)
		return
	}
	itemSchema.DiscardDefaultLinks()
	err = s.DB.CreateItemSchema(itemSchema)

	if err != nil {
		t.WriteError(err)
		return
	}

	itemSchema.AttachDefaultLinks(t.BaseUrl())
	t.WriteResultWithStatusCode(http.StatusCreated, itemSchema)
}
예제 #9
0
func (s *Server) findItemSchema(t *transaction.Transaction) {
	filter, err := db.NewFilterFromQueryString(t.Req.URL.RawQuery)

	if err != nil {
		t.WriteError(errors.Wraps(err, 400))
		return
	}

	reply, findErr := s.DB.FindItemSchema(filter)
	if findErr != nil {
		t.WriteError(findErr)
		return
	}

	baseUrl := t.BaseUrl()
	for _, itemSchema := range reply.Items {
		itemSchema.AttachDefaultLinks(baseUrl)
	}

	t.WriteResult(reply)
}