gondole.go
author Ollivier Robert <roberto@keltia.net>
Thu, 06 Apr 2017 23:37:26 +0200
changeset 26 dbc7755fbcca
parent 21 555716349f64
child 33 bce8b17415ae
permissions -rw-r--r--
Add a tailored version of prepareRequest().

package gondole

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

const (
	APIVersion = "0.0"

	APIEndpoint = "/api/v1"

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

// 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
}