You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
807 B
Go
38 lines
807 B
Go
// 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
|
|
}
|