| giolekva | a4a153b | 2020-05-12 11:49:53 +0400 | [diff] [blame] | 1 | package appmanager |
| 2 | |||||
| 3 | import ( | ||||
| 4 | "fmt" | ||||
| 5 | "net/http" | ||||
| 6 | "strings" | ||||
| 7 | ) | ||||
| 8 | |||||
| 9 | func InstallSchema(schema *Schema, apiAddr string) error { | ||||
| 10 | if schema == nil || len(schema.Schema) == 0 { | ||||
| 11 | return nil | ||||
| 12 | } | ||||
| 13 | resp, err := http.Post(apiAddr, "application/text", strings.NewReader(schema.Schema)) | ||||
| 14 | if err != nil { | ||||
| 15 | return err | ||||
| 16 | } | ||||
| 17 | if resp.StatusCode != http.StatusOK { | ||||
| 18 | return fmt.Errorf("Failed request with status code: %d", resp.StatusCode) | ||||
| 19 | } | ||||
| 20 | return nil | ||||
| 21 | } | ||||