mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Removed unused updating code and bmclib dependency and other minor changes
This commit is contained in:
parent
9b3c21a20a
commit
0922bbf5f9
5 changed files with 33 additions and 149 deletions
|
|
@ -9,6 +9,22 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
// HTTP aliases for readibility
|
||||
type HTTPHeader map[string]string
|
||||
type HTTPBody []byte
|
||||
|
||||
func (h HTTPHeader) Authorization(accessToken string) HTTPHeader {
|
||||
if accessToken != "" {
|
||||
h["Authorization"] = fmt.Sprintf("Bearer %s", accessToken)
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
func (h HTTPHeader) ContentType(contentType string) HTTPHeader {
|
||||
h["Content-Type"] = contentType
|
||||
return h
|
||||
}
|
||||
|
||||
// GetNextIP() returns the next IP address, but does not account
|
||||
// for net masks.
|
||||
func GetNextIP(ip *net.IP, inc uint) *net.IP {
|
||||
|
|
@ -35,7 +51,7 @@ func GetNextIP(ip *net.IP, inc uint) *net.IP {
|
|||
//
|
||||
// Returns a HTTP response object, response body as byte array, and any
|
||||
// error that may have occurred with making the request.
|
||||
func MakeRequest(client *http.Client, url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) {
|
||||
func MakeRequest(client *http.Client, url string, httpMethod string, body HTTPBody, header HTTPHeader) (*http.Response, HTTPBody, error) {
|
||||
// use defaults if no client provided
|
||||
if client == nil {
|
||||
client = http.DefaultClient
|
||||
|
|
@ -48,7 +64,7 @@ func MakeRequest(client *http.Client, url string, httpMethod string, body []byte
|
|||
return nil, nil, fmt.Errorf("failed to create new HTTP request: %v", err)
|
||||
}
|
||||
req.Header.Add("User-Agent", "magellan")
|
||||
for k, v := range headers {
|
||||
for k, v := range header {
|
||||
req.Header.Add(k, v)
|
||||
}
|
||||
res, err := client.Do(req)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue