Description

Handler is a net/http.Handler implementation that wraps a imageserver.Server.

Supported methods are: GET and HEAD. Other method will return a StatusMethodNotAllowed/405 response.

It supports ETag/If-None-Match headers and returns a StatusNotModified/304 response accordingly. But it doesn't check if the Image really exists (the Server is not called).

Steps:

- Parse the HTTP request, and fill the Params.
- If the given If-None-Match header matches the ETag, return a StatusNotModified/304 response.
- Call the Server and get the Image.
- Return a StatusOK/200 response containing the Image.

Errors (returned by Parser or Server):

- *imageserver/http.Error will return a response with the given status code and message.
- *imageserver.ParamError will return a StatusBadRequest/400 response, with a message including the resolved HTTP param.
- *imageserver.ImageError will return a StatusBadRequest/400 response, with the given message.
- Other error will return a StatusInternalServerError/500 response, and ErrorFunc will be called.

Returned headers:

- Content-Type is set for StatusOK/200 response, and contains "image/{Image.Format}".
- Content-Length is set for StatusOK/200 response, and contains the Image size.
- ETag is set for StatusOK/200 and StatusNotModified/304 response, and contains the ETag value.

Handler is referenced in 1 repository

github.com/pierrre/imageserver