http

package
v0.0.0-...-0345585 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package http provides an HTTP Handler for the imageserver package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewParametersHashETagFunc

func NewParametersHashETagFunc(newHashFunc func() hash.Hash) func(parameters imageserver.Parameters) string

NewParametersHashETagFunc returns a function that hashes the parameters and returns an ETag value

Types

type Error

type Error struct {
	Code int
	Text string
}

Error represent an http error

func NewError

func NewError(code int) *Error

NewError creates an Error with the message associated with the code

func NewErrorWithText

func NewErrorWithText(code int, text string) *Error

NewErrorWithText creates an Error

func (*Error) Error

func (err *Error) Error() string

type ImageHTTPHandler

type ImageHTTPHandler struct {
	Parser                                       // parse request to Parameters
	ImageServer imageserver.ImageServerInterface // handle image requests

	ETagFunc func(parameters imageserver.Parameters) string // optional
	Expire   time.Duration                                  // set the "Expires" header, optional

	RequestFunc  func(request *http.Request) error                                         // allows to handle incoming requests (and eventually return an error), optional
	HeaderFunc   func(header http.Header, request *http.Request, err error)                // allows to set custom headers, optional
	ErrorFunc    func(err error, request *http.Request)                                    // allows to handle internal errors, optional
	ResponseFunc func(request *http.Request, statusCode int, contentSize int64, err error) // allows to handle returned responses, optional
}

ImageHTTPHandler represents an HTTP Handler for imageserver.Server

func (*ImageHTTPHandler) ServeHTTP

func (handler *ImageHTTPHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP implements the HTTP Handler interface

Only GET and HEAD methods are supported.

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

type Parser

type Parser interface {
	Parse(*http.Request, imageserver.Parameters) error
}

Parser represents a http parser

It parses the Tequest and fill Parameters.

Directories

Path Synopsis
parser
graphicsmagick
Package graphicsmagick provides a GraphicsMagick http Parser
Package graphicsmagick provides a GraphicsMagick http Parser
list
Package list provides a list of http Parser
Package list provides a list of http Parser
source
Package source provides an http Parser that takes the "source" parameter from query
Package source provides an http Parser that takes the "source" parameter from query
sourcepath
Package sourcepath provides an http Parser that takes the "source" parameter from the path
Package sourcepath provides an http Parser that takes the "source" parameter from the path

Jump to

Keyboard shortcuts

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