parse

package module
v0.0.0-...-835ea0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2015 License: BSD-3-Clause Imports: 7 Imported by: 30

README

parse Build Status

NOTE: The APIs for this package are still in flux.

Package parse provides a client for the Parse API: https://godoc.org/github.com/facebookgo/parse

Documentation

Overview

Package parse provides a client for the Parse API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// The underlying http.RoundTripper to perform the individual requests. When
	// nil http.DefaultTransport will be used.
	Transport http.RoundTripper

	// The base URL to parse relative URLs off. If you pass absolute URLs to
	// Client functions they are used as-is. When nil, the production Parse URL
	// will be used.
	BaseURL *url.URL

	// Credentials if set, will be included on every request.
	Credentials Credentials

	// UserAgent to use in the User-Agent header.  When nil defaultUserAgent
	// will be used.
	UserAgent string
}

Client provides access to the Parse API.

func (*Client) Delete

func (c *Client) Delete(u *url.URL, result interface{}) (*http.Response, error)

Delete performs a DELETE method call on the given url and unmarshal response into result.

func (*Client) Do

func (c *Client) Do(req *http.Request, body, result interface{}) (*http.Response, error)

Do performs a Parse API call. This method modifies the request and adds the Authentication headers. The body is JSON encoded and for responses in the 2xx or 3xx range the response will be JSON decoded into result, for others an error of type Error will be returned.

func (*Client) Get

func (c *Client) Get(u *url.URL, result interface{}) (*http.Response, error)

Get performs a GET method call on the given url and unmarshal response into result.

func (*Client) Post

func (c *Client) Post(u *url.URL, body, result interface{}) (*http.Response, error)

Post performs a POST method call on the given url with the given body and unmarshal response into result.

func (*Client) Put

func (c *Client) Put(u *url.URL, body, result interface{}) (*http.Response, error)

Put performs a PUT method call on the given url with the given body and unmarshal response into result.

func (*Client) RoundTrip

func (c *Client) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip performs a RoundTrip ignoring the request and response bodies. It is up to the caller to close them. This method modifies the request.

func (*Client) WithCredentials

func (c *Client) WithCredentials(cr Credentials) *Client

WithCredentials returns a new instance of the Client using the given Credentials. It discards the previous Credentials.

type Credentials

type Credentials interface {
	Modify(r *http.Request) error
}

Credentials allows for adding authentication information to a request.

type Error

type Error struct {
	Message string `json:"error"`
	Code    int    `json:"code"`
}

An Error from the Parse API. When a valid Parse JSON error is found, the returned error will be of this type.

func (*Error) Error

func (e *Error) Error() string

type MasterKey

type MasterKey struct {
	ApplicationID string
	MasterKey     string
}

MasterKey adds the Master Key to the request.

func (MasterKey) Modify

func (m MasterKey) Modify(r *http.Request) error

Modify adds the Master Key header.

type RawError

type RawError struct {
	StatusCode int
	Body       []byte
}

A RawError with the HTTP StatusCode and Body. When a valid Parse JSON error is not found, the returned error will be of this type.

func (*RawError) Error

func (e *RawError) Error() string

type RestAPIKey

type RestAPIKey struct {
	ApplicationID string
	RestAPIKey    string
}

RestAPIKey adds the Rest API Key to the request.

func (RestAPIKey) Modify

func (k RestAPIKey) Modify(r *http.Request) error

Modify adds the Rest API Key header.

type SessionToken

type SessionToken struct {
	ApplicationID string
	RestAPIKey    string
	SessionToken  string
}

SessionToken adds the Rest API Key and the Session Token to the request.

func (SessionToken) Modify

func (t SessionToken) Modify(r *http.Request) error

Modify adds the Session Token header.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL