http

package
v0.0.0-...-60e87b8 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package http provides a HTTP Handler for an Image Server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewParamsHashETagFunc

func NewParamsHashETagFunc(newHashFunc func() hash.Hash) func(params imageserver.Params) string

NewParamsHashETagFunc returns a function that hashes the params and returns an ETag value.

func ParseQueryBool

func ParseQueryBool(param string, req *http.Request, params imageserver.Params) error

ParseQueryBool takes the param from the query string, parse it as an bool and add it to params.

func ParseQueryFloat

func ParseQueryFloat(param string, req *http.Request, params imageserver.Params) error

ParseQueryFloat takes the param from the query string, parse it as a float64 and add it to params.

func ParseQueryInt

func ParseQueryInt(param string, req *http.Request, params imageserver.Params) error

ParseQueryInt takes the param from the query string, parse it as an int and add it to params.

func ParseQueryString

func ParseQueryString(param string, req *http.Request, params imageserver.Params)

ParseQueryString takes the param from the query string and add it to params.

Types

type CacheControlPublicHandler

type CacheControlPublicHandler struct {
	http.Handler
}

CacheControlPublicHandler is a net/http.Handler implementation that sets the "Cache-Control" header to "public". It only sets the header if the status code is StatusOK/204 or StatusNotModified/304.

func (*CacheControlPublicHandler) ServeHTTP

func (h *CacheControlPublicHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type Error

type Error struct {
	Code int
	Text string
}

Error is a HTTP error.

func NewErrorDefaultText

func NewErrorDefaultText(code int) *Error

NewErrorDefaultText creates an Error with the message associated with the code.

func (*Error) Error

func (err *Error) Error() string

type ExpiresHandler

type ExpiresHandler struct {
	http.Handler
	Expires time.Duration
}

ExpiresHandler is a HTTP Handler that sets "Expires" header. It only sets the header if the status code is StatusOK/204 or StatusNotModified/304.

func (*ExpiresHandler) ServeHTTP

func (eh *ExpiresHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type Handler

type Handler struct {
	Parser    Parser                                 // parse request to Params
	Server    imageserver.Server                     // handle image requests
	ETagFunc  func(params imageserver.Params) string // optional
	ErrorFunc func(err error, req *http.Request)     // allows to handle internal errors, optional
}

Handler is a HTTP Handler for imageserver.Server.

Only GET and HEAD methods are supported.

Supports ETag/If-None-Match (status code 304). It doesn't check if the image really exists.

func (*Handler) ServeHTTP

func (handler *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type ListParser

type ListParser []Parser

ListParser is a list of HTTP Parser.

func (ListParser) Parse

func (lp ListParser) Parse(req *http.Request, params imageserver.Params) error

Parse implements Parser.

func (ListParser) Resolve

func (lp ListParser) Resolve(param string) string

Resolve implements Parser.

type Parser

type Parser interface {
	// Parse parses a Request and fill Params.
	Parse(*http.Request, imageserver.Params) error

	// Resolve resolves a param to a HTTP param.
	// It returns the resolved HTTP param, or an empty string.
	Resolve(param string) (httpParam string)
}

Parser represents a HTTP Request parser.

type SourceParser

type SourceParser struct{}

SourceParser is a HTTP Parser that takes the "source" param from the query.

func (*SourceParser) Parse

func (parser *SourceParser) Parse(req *http.Request, params imageserver.Params) error

Parse implements Parser.

func (*SourceParser) Resolve

func (parser *SourceParser) Resolve(param string) string

Resolve implements Parser.

type SourcePathParser

type SourcePathParser struct{}

SourcePathParser is a HTTP Parser that takes the "source" param from the path.

func (*SourcePathParser) Parse

func (parser *SourcePathParser) Parse(req *http.Request, params imageserver.Params) error

Parse implements Parser.

func (*SourcePathParser) Resolve

func (parser *SourcePathParser) Resolve(param string) string

Resolve implements Parser.

type SourcePrefixParser

type SourcePrefixParser struct {
	Parser
	Prefix string
}

SourcePrefixParser is a HTTP Parser that adds a prefix to the "source" param.

func (*SourcePrefixParser) Parse

func (ps *SourcePrefixParser) Parse(req *http.Request, params imageserver.Params) error

Parse implements Parser.

type SourceTransformParser

type SourceTransformParser struct {
	Parser
	Transform func(source string) string
}

SourceTransformParser is a HTTP Parser that transforms the "source" param.

func (*SourceTransformParser) Parse

func (ps *SourceTransformParser) Parse(req *http.Request, params imageserver.Params) error

Parse implements Parser.

Directories

Path Synopsis
Package gamma provides a imageserver/http.Parser implementation for imageserver/image/gamma.CorrectionProcessor.
Package gamma provides a imageserver/http.Parser implementation for imageserver/image/gamma.CorrectionProcessor.
Package gift provides a GIFT HTTP Parser
Package gift provides a GIFT HTTP Parser
Package graphicsmagick provides a GraphicsMagick HTTP Parser.
Package graphicsmagick provides a GraphicsMagick HTTP Parser.
Package image provides imageserver/http.Parser implementations for imageserver/image.
Package image provides imageserver/http.Parser implementations for imageserver/image.
Package nfntresize provides a nfnt resize HTTP Parser.
Package nfntresize provides a nfnt resize HTTP Parser.

Jump to

Keyboard shortcuts

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