libpixel

package module
v0.0.0-...-cdbd6a2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2015 License: MIT Imports: 4 Imported by: 0

README

LibPixel

GoDoc Build Status

Go library to generate and sign LibPixel URLs.

Installation

$ go get github.com/libpixel/libpixel-go

Usage

Usage documentation with examples available on GoDoc.

License

MIT

Documentation

Overview

Package libpixel provides a Client to generate and sign LibPixel URLs.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host   string
	HTTPS  bool
	Secret string
}

The Client to sign and/or generate URLs with.

func (*Client) Sign

func (c *Client) Sign(uri string) (string, error)

Sign generates and adds a signature to a URL. A Secret must be provided in the Client for this method to work. Returns the signed URL.

Example
c := &Client{Secret: "TOP-SECRET"}
url, err := c.Sign("http://test.libpx.com/images/1.jpg")
if err == nil {
	fmt.Println(url)
}
Output:

http://test.libpx.com/images/1.jpg?signature=e20add8e4c64f38c1a3bf27a6ba816f6ce85b40f

func (*Client) URL

func (c *Client) URL(path string, params Params) (string, error)

URL generates a LibPixel URL for a given path and Params. If the Client has a Secret defined, the URL will automatically be signed. The Client must define a Host for this method to work. Returns the generated URL.

Example
c := &Client{Host: "test.libpx.com", Secret: "TOP-SECRET"}
url, err := c.URL("/images/1.jpg", Params{"width": 600, "blur": 20})
if err == nil {
	fmt.Println(url)
}
Output:

http://test.libpx.com/images/1.jpg?blur=20&width=600&signature=199cb62b964d9ddef84eaf3a7df30d41fa398b74

type Params

type Params map[string]interface{}

Params for the LibPixel Image API.

For API documentation, see: http://libpixel.com/docs/#image-api

Jump to

Keyboard shortcuts

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