blob: 762868690fb26c6ef91cfa8bbc67ac94a064fe1d [file] [log] [blame]
package appmanager
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func InstallSchema(schema Schema, apiAddr string) error {
if len(schema.Schema) == 0 {
return nil
}
resp, err := http.Post(apiAddr, "application/text", strings.NewReader(schema.Schema))
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(resp.Body)
return fmt.Errorf("Failed request with status code: %d %s", resp.StatusCode, string(body))
}
return nil
}