예제 #1
0
// IndexesReport shows the status of indexes in query options
func indexesReport(c *clients.Client, response handle.ResponseHandle) error {
	req, err := http.NewRequest("GET", c.Base()+"/config/indexes", nil)
	if err != nil {
		return err
	}
	return util.Execute(c, req, response)
}
예제 #2
0
func read(c *clients.Client, uris []string, categories []string, transform *util.Transform, response handle.ResponseHandle) error {
	params := buildParameters(uris, categories, nil, nil, nil, transform)
	req, err := http.NewRequest("GET", c.Base()+"/documents"+params, nil)
	if err != nil {
		return err
	}
	return util.Execute(c, req, response)
}
예제 #3
0
// CreateResource installs a REST service
func createResource(c *clients.Client, name string, resource io.Reader, extensionType string, options map[string]string, response handle.ResponseHandle) error {
	params := mapToParams(options)
	req, err := http.NewRequest("PUT", c.Base()+"/config/resources/"+name+params, resource)
	if err != nil {
		return err
	}
	req.Header.Add("Content-Type", "application/"+extensionType)
	return util.Execute(c, req, response)
}
예제 #4
0
func write(c *clients.Client, documents []DocumentDescription, transform *util.Transform, response handle.ResponseHandle) error {
	channel := make(chan error)
	var err error
	for _, doc := range documents {
		go func(doc DocumentDescription) {
			params := buildParameters([]string{doc.URI}, nil, doc.Collections, doc.Permissions, doc.Properties, transform)
			req, err := http.NewRequest("PUT", c.Base()+"/documents"+params, doc.Content)
			if err == nil {
				err = util.Execute(c, req, response)
			}
			channel <- err
		}(doc)
	}
	for _ = range documents {
		if err == nil {
			err = <-channel
		} else {
			<-channel
		}
	}
	return err
}