Documentation ¶
Overview ¶
Package core provides an extensible core implementation as well as standard handlers for a http server.
Index ¶
- func DefaultServe(w http.ResponseWriter, r Resource) error
- func SetDefaultHeaders(w http.ResponseWriter, info ResourceInfo)
- type Core
- func (c *Core) ApplyExtension(ext Extension) *Core
- func (c *Core) ApplyGetObject(decorator HandlerDecorator) *Core
- func (c *Core) ApplyHeader(decorator HeaderHandlerDecorator) *Core
- func (c *Core) ApplyServe(decorator ServeHandlerDecorator) *Core
- func (c *Core) ApplyStatObject(decorator HandlerDecorator) *Core
- func (c *Core) ChainGetObject(handler Handler) *Core
- func (c *Core) ChainStatObject(handler Handler) *Core
- func (c *Core) Init() *Core
- type Extension
- type Handler
- type HandlerDecorator
- type Handlers
- type HandlersToUse
- type HeaderHandler
- type HeaderHandlerDecorator
- type Resource
- type ResourceInfo
- type ServeHandler
- type ServeHandlerDecorator
- type Sugared
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultServe ¶
func DefaultServe(w http.ResponseWriter, r Resource) error
DefaultServe serve the Resource.
func SetDefaultHeaders ¶
func SetDefaultHeaders(w http.ResponseWriter, info ResourceInfo)
SetDefaultHeaders set headers for the http response.
Types ¶
type Core ¶
Core describes the state of application
func (*Core) ApplyExtension ¶
ApplyExtension applies an extension on core state.
func (*Core) ApplyGetObject ¶
func (c *Core) ApplyGetObject(decorator HandlerDecorator) *Core
ApplyGetObject decorate the current GetObject handler.
func (*Core) ApplyHeader ¶
func (c *Core) ApplyHeader(decorator HeaderHandlerDecorator) *Core
ApplyHeader decorate the current Header handler.
func (*Core) ApplyServe ¶
func (c *Core) ApplyServe(decorator ServeHandlerDecorator) *Core
ApplyServe decorate the current Serve handler.
func (*Core) ApplyStatObject ¶
func (c *Core) ApplyStatObject(decorator HandlerDecorator) *Core
ApplyStatObject decorate the current StatObject handler.
func (*Core) ChainGetObject ¶
ChainGetObject applies a GetObject handler.
func (*Core) ChainStatObject ¶
ChainStatObject applies a StatObject handler.
type Handler ¶
Handler is a returns a Resource with a provided url.
func ChainHandlers ¶
ChainHandlers returns a new handler that chains handlers sequetially
type HandlerDecorator ¶
HandlerDecorator decorates a Handler.
type Handlers ¶
type Handlers struct { StatObject func(url string) (Resource, error) GetObject func(url string) (Resource, error) ListFolder func(url string) (Resource, error) SetHeaders func(w http.ResponseWriter, info ResourceInfo) Serve func(w http.ResponseWriter, r Resource) error Sugared }
Handlers describes how to get Resource metadata, retrieve Resource from S3 compatible backend, how to set the Headers, as well as how to serve the Resource.
func (*Handlers) GetHandler ¶
func (h *Handlers) GetHandler(w http.ResponseWriter, r *http.Request)
GetHandler handles the request when method is GET.
func (*Handlers) Handler ¶
func (h *Handlers) Handler() func(w http.ResponseWriter, r *http.Request)
Handler sets some defaults and returns a handler function.
func (*Handlers) HeadHandler ¶
func (h *Handlers) HeadHandler(w http.ResponseWriter, r *http.Request)
HeadHandler handles the request when method is HEAD.
type HandlersToUse ¶
HandlersToUse describes the types of handlers.
type HeaderHandler ¶
type HeaderHandler = func(w http.ResponseWriter, info ResourceInfo)
HeaderHandler handles the response header with the provided resource info.
type HeaderHandlerDecorator ¶
type HeaderHandlerDecorator = func(HeaderHandler) HeaderHandler
HeaderHandlerDecorator decorates a HeaderHandler.
type Resource ¶
type Resource struct { Data io.Reader Info ResourceInfo Msg string }
Resource represents the retrieved resource from the S3 compatible backend to be streamed.
type ResourceInfo ¶
type ResourceInfo struct { Key string Size int64 ETag string ContentType string LastModified time.Time }
ResourceInfo describes the metadata of the resource.
type ServeHandler ¶
type ServeHandler = func(w http.ResponseWriter, r Resource) error
ServeHandler handles the serving of a resource.
type ServeHandlerDecorator ¶
type ServeHandlerDecorator = func(ServeHandler) ServeHandler
ServeHandlerDecorator decorates a ServeHandler.
type Sugared ¶ added in v0.2.1
type Sugared struct {
Sugar *zap.SugaredLogger
}
Sugared can be used to composite other object witj a sugared logger