util

package
v0.0.0-...-6217932 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Some incoming HTTP requests might take a long time to reach
	// the backend if we have a buffering proxy on the frontend
	// (for instance, NGINX). Relax the allowed delay.
	MaxTimeSkew = 12 * 3600.0

	// Authorization errors.
	BadAuth      = errors.New("Bad authenticated request")
	Unauthorized = errors.New("Unauthorized")
	AuthFailed   = errors.New("Authentication failed")
)

Functions

func AuthenticateHttpRequest

func AuthenticateHttpRequest(getAuth func(string) (*api.AuthKey, bool), r *http.Request) (*api.AuthKey, error)

Authenticate checks the Authorization header in the request, and verifies its validity. It accepts a function to retrieve authentication keys from a database or other source.

func ExpandTilde

func ExpandTilde(path string) string

func GetHttpRequestSignature

func GetHttpRequestSignature(secret string, r *http.Request) string

GetHttpRequestSignature returns the signature of a HTTP request.

func ListenAndServe

func ListenAndServe(addr string, handler http.Handler) error

func ListenAndServeWithTimeout

func ListenAndServeWithTimeout(addr string, handler http.Handler, timeout time.Duration) error

func SignHttpRequest

func SignHttpRequest(key *api.AuthKey, r *http.Request)

SignHttpRequests adds a HMAC Authorization header with a signature to a HTTP request.

Types

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(baseUrl string, authKey *api.AuthKey, caPool *x509.CertPool) *HttpClient

func (*HttpClient) DoJSON

func (h *HttpClient) DoJSON(c *http.Client, r *http.Request, resp interface{}) error

func (*HttpClient) Get

func (h *HttpClient) Get(url string, resp interface{}) error

func (*HttpClient) GetRaw

func (h *HttpClient) GetRaw(url string) (*http.Response, error)

func (*HttpClient) GetRawRange

func (h *HttpClient) GetRawRange(url string, beg, end int64) (*http.Response, error)

func (*HttpClient) NewRequest

func (h *HttpClient) NewRequest(method, relUrl string, data io.Reader) (*http.Request, error)

func (*HttpClient) Post

func (h *HttpClient) Post(url string, req interface{}, resp interface{}) error

PostJSON performs a POST request with a JSON-encoded payload.

func (*HttpClient) Put

func (h *HttpClient) Put(url string, in io.Reader, size int64, resp interface{}) error

type RestartableTimer

type RestartableTimer struct {
	C chan time.Time
	// contains filtered or unexported fields
}

func NewRestartableTimer

func NewRestartableTimer() *RestartableTimer

func (*RestartableTimer) Reset

func (rt *RestartableTimer) Reset(d time.Duration)

Directories

Path Synopsis
Compute audio fingerprints of songs using the Echonest analyzers.
Compute audio fingerprints of songs using the Echonest analyzers.

Jump to

Keyboard shortcuts

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