working commit

This commit is contained in:
2026-02-11 12:53:31 +02:00
parent 517c518df2
commit 6fe7f7c15e
12 changed files with 392 additions and 186 deletions
+21 -14
View File
@@ -13,40 +13,47 @@ import (
"context"
"crypto/tls"
"net/http"
"net/url"
"time"
)
type Client struct {
username string
password string
}
type Client struct{}
func NewClient() *Client {
return &Client{}
}
func NewClientWithAuth(username, password string) *Client {
return &Client{
username: username,
password: password,
func convertServiceURI(ref string) (string, error) {
var err error
var res string
const serviceAPI = "/v3/api/service/"
const serviceScheme = "https"
uri, err := url.Parse(ref)
if err != nil {
return res, err
}
uri.Path = serviceAPI
uri.Scheme = serviceScheme
res = uri.String()
return res, err
}
func (cli *Client) ServiceHello(ctx context.Context, ref string, timeout time.Duration) (bool, error) {
func (cli *Client) ServiceHello(ctx context.Context, serviceuri string, timeout time.Duration) (bool, error) {
var res bool
var err error
ctx, _ = context.WithTimeout(ctx, timeout)
ref, err = convertServiceRefer(ref)
serviceuri, _, _, err = repackServiceURI(serviceuri)
if err != nil {
return res, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, ref, nil)
serviceuri, err = convertServiceURI(serviceuri)
if err != nil {
return res, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, serviceuri, nil)
if err != nil {
return res, err
}
transport := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,