Example #1
0
func parsePackageRequest(r io.Reader) (*install.PackageRequest, error) {
	body, err := ioutil.ReadAll(r)
	if err != nil {
		log.Errorf("Unable to read request body: %v", err)
		return nil, err
	}

	pkgRequest, err := install.NewPackageRequest(body)
	if err != nil {
		return nil, err
	}

	return pkgRequest, nil
}
Example #2
0
func (api *Api) parsePackageRequest(r io.Reader, pkgName string) (*install.PackageRequest, error) {
	body, err := ioutil.ReadAll(r)
	if err != nil {
		log.Errorf("Unable to read request body: %v", err)
		return nil, err
	}

	pkgRequest, err := install.NewPackageRequest(body)
	if err != nil {
		return nil, err
	}

	if pkgName != "" {
		pkgRequest.Name = pkgName
	}

	return pkgRequest, nil
}