diff -r ba90955d2d56 -r adc39ae774c0 gondole.go --- a/gondole.go Wed Apr 12 14:27:09 2017 +0200 +++ b/gondole.go Wed Apr 12 16:40:02 2017 +0200 @@ -1,51 +1,43 @@ package gondole import ( - "github.com/sendgrid/rest" + "errors" "fmt" - "errors" + + "github.com/sendgrid/rest" ) const ( - APIVersion = "0.0" + // GondoleVersion contains the version of the Gondole implementation + GondoleVersion = "0.0" - // That is not overridable - apiURL = "/api/v1" + defaultInstanceURL = "https://mastodon.social" + apiVersion = "v1" // That is not overridable + defaultAPIPath = "/api/" + apiVersion - // Fallback instance - FallBackURL = "https://mastodon.social" - + // NoRedirect is the URI for no redirection in the App registration NoRedirect = "urn:ietf:wg:oauth:2.0:oob" ) var ( - APIEndpoint string ErrAlreadyRegistered = errors.New("App already registered") ) // prepareRequest insert all pre-defined stuff func (g *Client) prepareRequest(what string) (req rest.Request) { - var APIBase string + var endPoint string - // Allow for overriding for registration - if g.APIBase == "" { - APIBase = FallBackURL - } else { - APIBase = g.APIBase - } - - APIEndpoint = fmt.Sprintf("%s%s/%", APIBase, apiURL, what) - + endPoint = g.APIBase + "/" + 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("Client/%s", APIVersion) + hdrs["User-Agent"] = fmt.Sprintf("Gondole/%s", GondoleVersion) hdrs["Authorization"] = fmt.Sprintf("Bearer %s", g.Secret) req = rest.Request{ - BaseURL: APIEndpoint, + BaseURL: endPoint, Headers: hdrs, QueryParams: opts, }