feat: support secure connections

This commit is contained in:
Dominik Siebel
2024-02-22 11:28:05 +01:00
parent a9aad16cf3
commit 8b436ce4ee
3 changed files with 56 additions and 6 deletions

View File

@@ -16,8 +16,24 @@ type HttpClient struct {
}
func NewHttpClient(ip, port, token string) *HttpClient {
url := fmt.Sprintf("http://%s:%s/api", ip, port)
return &HttpClient{url, token}
return ClientFromUri(
fmt.Sprintf("http://%s:%s/api", ip, port),
token,
)
}
func NewHttpsClient(ip, port, token string) *HttpClient {
return ClientFromUri(
fmt.Sprintf("https://%s:%s/api", ip, port),
token,
)
}
func ClientFromUri(uri, token string) *HttpClient {
return &HttpClient{
uri,
token,
}
}
func (c *HttpClient) GetState(entityId string) ([]byte, error) {