gondole.go
author Ollivier Robert <roberto@keltia.net>
Mon, 10 Apr 2017 19:36:10 +0200
changeset 45 c1fd96210492
parent 43 e52d68c19cb0
child 67 1ff7afce37fe
permissions -rw-r--r--
Add test for loadGlobal().

package gondole

import (
	"github.com/sendgrid/rest"
	"fmt"
	"errors"
)

const (
	APIVersion = "0.0"

	APIEndpoint = "https://mastodon.social/api/v1"

	NoRedirect = "urn:ietf:wg:oauth:2.0:oob"
)

var (
	ErrAlreadyRegistered = errors.New("App already registered")
)

// prepareRequest insert all pre-defined stuff
func (g *Gondole) prepareRequest(what string) (req rest.Request) {
	endPoint := APIEndpoint + fmt.Sprintf("/%s", what)

	// Add at least one option, the APIkey if present
	hdrs := make(map[string]string)
	opts := make(map[string]string)

	// Insert our sig
	hdrs["User-Agent"] = fmt.Sprintf("Gondole/%s", APIVersion)

	req = rest.Request{
		BaseURL:     endPoint,
		Headers:     hdrs,
		QueryParams: opts,
	}
	return
}