1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pasteapi.go/client_server.go

38 lines
807 B

// Copyright 2022 Leonid Maslakov. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package pasteapi
import (
"encoding/json"
"net/http"
)
// GetServerInfo returns information about the server in use
// (including header and body length limits and maximum possible lifetime).
func (server Server) GetServerInfo() (ServerInfo, error) {
var info ServerInfo
// Make GET request
resp, err := http.Get(server.Server + "/api/v1/getServerInfo")
if err != nil {
return info, err
}
defer resp.Body.Close()
// Check HTTP response code
err = checkStatus(resp)
if err != nil {
return info, err
}
// Parse answer
err = json.NewDecoder(resp.Body).Decode(&info)
if err != nil {
return info, err
}
return info, nil
}