Documentation ¶
Overview ¶
Package ghastly provides a golang interface for using the Fastly (http://www.fastly.com) CDN's API.
Index ¶
- Constants
- func ParseJson(data io.ReadCloser) (map[string]interface{}, error)
- func ParseJsonArray(data io.ReadCloser) ([]interface{}, error)
- func ProxyFromEnvironment(req *http.Request) (*url.URL, error)
- func ProxyURL(fixedURL *url.URL) func(*http.Request) (*url.URL, error)
- type Client
- func (c *Client) Delete(url string, contentType ...string) (*http.Response, error)
- func (c *Client) Get(url string) (*http.Response, error)
- func (c *Client) GetParams(baseURL string, queryParams map[string]string) (*http.Response, error)
- func (c *Client) Post(url string, bodyType string, body io.Reader) (*http.Response, error)
- func (c *Client) PostForm(url string, data url.Values) (*http.Response, error)
- func (c *Client) PostFormParams(url string, params map[string]string) (*http.Response, error)
- func (c *Client) Purge(purgeUrl string, contentType ...string) (*http.Response, error)
- func (c *Client) Put(url string, data url.Values, contentType ...string) (*http.Response, error)
- func (c *Client) PutParams(url string, params map[string]string) (*http.Response, error)
- type Domain
- type DomainCheck
- type Ghastly
- type Service
- func (s *Service) Delete() error
- func (s *Service) Details() (*Service, error)
- func (s *Service) GetVersion(number int64) (*Version, error)
- func (s *Service) NewVersion() (*Version, error)
- func (s *Service) PurgeAll() error
- func (s *Service) PurgeKey(key string) error
- func (s *Service) TaskURL(taskPath string) string
- func (s *Service) Update(params map[string]string) error
- type Transport
- type Version
- func (v *Version) CheckAllDomains() ([]*DomainCheck, error)
- func (v *Version) CheckDomain(name string) (*DomainCheck, error)
- func (v *Version) Clone() (*Version, error)
- func (v *Version) GetDomain(name string) (*Domain, error)
- func (v *Version) ListDomains() ([]*Domain, error)
- func (v *Version) NewDomain(params map[string]string) (*Domain, error)
- type VersionNetwork
Constants ¶
const DefaultMaxIdleConnsPerHost = 2
DefaultMaxIdleConnsPerHost is the default value of Transport's MaxIdleConnsPerHost.
Variables ¶
This section is empty.
Functions ¶
func ParseJsonArray ¶
func ParseJsonArray(data io.ReadCloser) ([]interface{}, error)
func ProxyFromEnvironment ¶
ProxyFromEnvironment returns the URL of the proxy to use for a given request, as indicated by the environment variables $HTTP_PROXY and $NO_PROXY (or $http_proxy and $no_proxy). An error is returned if the proxy environment is invalid. A nil URL and nil error are returned if no proxy is defined in the environment, or a proxy should not be used for the given request.
Types ¶
type Client ¶
type Client struct { ApiKey string User string Password string BaseUrl string Http *http.Client PurgeHttp *http.Client }
func (*Client) PostFormParams ¶
Post a form to the server with a map[string]string of paramaters.
type Domain ¶
type Domain struct { Name string Comment string ServiceId string Version int64 Locked bool // contains filtered or unexported fields }
type DomainCheck ¶
type Ghastly ¶
type Ghastly struct {
*Client
}
func (*Ghastly) GetService ¶
Get a service with the ID string.
func (*Ghastly) ListServices ¶
List the current services.
func (*Ghastly) NewService ¶
Create a new service.
type Service ¶
type Service struct { Id string Name string CustomerId string PublishKey string Comment string ActiveVersion int64 UpdatedAt time.Time CreatedAt time.Time // contains filtered or unexported fields }
A Service is a particular website, app, etc. served through Fastly. They are configured with different versions, which have backends, domains, etc.
func (*Service) GetVersion ¶
Get a particular version of this service identified by the version number.
func (*Service) NewVersion ¶
Create a brand new, pristine version of a service, with nothing in it.
type Transport ¶
type Transport struct { // Proxy specifies a function to return a proxy for a given // Request. If the function returns a non-nil error, the // request is aborted with the provided error. // If Proxy is nil or returns a nil *URL, no proxy is used. Proxy func(*http.Request) (*url.URL, error) // Dial specifies the dial function for creating TCP // connections. // If Dial is nil, net.Dial is used. Dial func(network, addr string) (net.Conn, error) // TLSClientConfig specifies the TLS configuration to use with // tls.Client. If nil, the default configuration is used. TLSClientConfig *tls.Config // DisableKeepAlives, if true, prevents re-use of TCP connections // between different HTTP requests. DisableKeepAlives bool // DisableCompression, if true, prevents the Transport from // requesting compression with an "Accept-Encoding: gzip" // request header when the Request contains no existing // Accept-Encoding value. If the Transport requests gzip on // its own and gets a gzipped response, it's transparently // decoded in the Response.Body. However, if the user // explicitly requested gzip it is not automatically // uncompressed. DisableCompression bool // MaxIdleConnsPerHost, if non-zero, controls the maximum idle // (keep-alive) to keep per-host. If zero, // DefaultMaxIdleConnsPerHost is used. MaxIdleConnsPerHost int // ResponseHeaderTimeout, if non-zero, specifies the amount of // time to wait for a server's response headers after fully // writing the request (including its body, if any). This // time does not include the time to read the response body. ResponseHeaderTimeout time.Duration // PurgeBaseURL, used to craft PURGE requests for individual items where // the URL in the PURGE command (ex. PURGE http://example.com/foo.jpg) is // not on the server the PURGE command is being sent to (like // api.fastly.com). PurgeBaseURL *url.URL // contains filtered or unexported fields }
Transport is an implementation of RoundTripper that supports http, https, and http proxies (for either http or https with CONNECT). Transport can also cache connections for future re-use.
func (*Transport) CancelRequest ¶
CancelRequest cancels an in-flight request by closing its connection.
func (*Transport) CloseIdleConnections ¶
func (t *Transport) CloseIdleConnections()
CloseIdleConnections closes any connections which were previously connected from previous requests but are now sitting idle in a "keep-alive" state. It does not interrupt any connections currently in use.
func (*Transport) RegisterProtocol ¶
func (t *Transport) RegisterProtocol(scheme string, rt http.RoundTripper)
RegisterProtocol registers a new protocol with scheme. The Transport will pass requests using the given scheme to rt. It is rt's responsibility to simulate HTTP request semantics.
RegisterProtocol can be used by other packages to provide implementations of protocol schemes like "ftp" or "file".
type Version ¶
type Version struct { Number int64 ServiceId string Active bool Locked bool Comment string Testing bool Staging bool Deployed bool Network VersionNetwork // contains filtered or unexported fields }
A version of the configuration for a particular service. Backends, domains, etc. belong to a particular version.
func (*Version) CheckAllDomains ¶
func (v *Version) CheckAllDomains() ([]*DomainCheck, error)
Check all domains associated with a version of a service.
func (*Version) CheckDomain ¶
func (v *Version) CheckDomain(name string) (*DomainCheck, error)
Check one domain associated with a service.
func (*Version) ListDomains ¶
List all domains associated with a version of a service.