improving client/server info command

This commit is contained in:
2020-06-07 18:31:01 -04:00
parent dd3fd7c4ae
commit 6d738b138d
12 changed files with 72 additions and 31 deletions

View File

@@ -6,18 +6,24 @@ import (
"github.com/go-resty/resty/v2"
)
// GetServerInfo queries the supplied server name for information about the current repo from the server
func GetServerInfo() error {
serverURL := "http://localhost:80/info/"
// GetServerInfo queries the supplied connection string for server info and uses the provided repoName to get repo specific information
func GetServerInfo(connectionString string, repoName string) error {
serverURL := connectionString + "/info/" //creating the full string to get info
client := resty.New()
resp, err := client.R().
SetPathParams(map[string]string{
"repoName": "testRepo",
"repoName": repoName,
}).
Get(serverURL + "{repoName}")
if err != nil {
return fmt.Errorf("error connecting to server at: %s: error was: %s", serverURL, err)
}
if resp.IsError() {
if resp.StatusCode() == 404 {
return fmt.Errorf("error: repo was not found on server, 404: %s", resp.Request.URL)
}
return fmt.Errorf("reponse not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL)
}
fmt.Println(resp)
return nil
}