Documentation
¶
Overview ¶
Package webserver contains the webserver which deals with processing requests from the user, presenting him with the interface of the application.
Index ¶
- func InternalErrorOnErrorHandler(writer http.ResponseWriter, req *http.Request, ...)
- func NewGzipHandler(handler http.Handler) http.Handler
- func NewTerryHandler(handler http.Handler) http.Handler
- type AlbumHandler
- type BasicAuthHandler
- type BrowseHandler
- type FileHandler
- type GzipHandler
- type SearchHandler
- type Server
- type TerryHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InternalErrorOnErrorHandler ¶
func InternalErrorOnErrorHandler(writer http.ResponseWriter, req *http.Request, fnc func(http.ResponseWriter, *http.Request) error)
InternalErrorOnErrorHandler is used to wrap around handlers-like functions which just return error. This function actually writes the HTTP error and renders the error in the html.
func NewGzipHandler ¶
NewGzipHandler returns GzipHandler which will gzip anything written in the supplied handler. Must be the main handler given to the net.Server
Types ¶
type AlbumHandler ¶
type AlbumHandler struct {
// contains filtered or unexported fields
}
AlbumHandler is a http.Handler which will find and serve a zip of the album by the album ID.
func NewAlbumHandler ¶
func NewAlbumHandler(lib library.Library) *AlbumHandler
NewAlbumHandler returns a new Album handler. It needs a library to search in
func (AlbumHandler) ServeHTTP ¶
func (fh AlbumHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP is required by the http.Handler's interface
type BasicAuthHandler ¶
type BasicAuthHandler struct {
// contains filtered or unexported fields
}
BasicAuthHandler is a handler wrapper used for basic authenticate. Its only job is to do the authentication and then pass the work to the Handler it wraps around
func (BasicAuthHandler) ServeHTTP ¶
func (hl BasicAuthHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface and does the actual basic authenticate check for every request
type BrowseHandler ¶ added in v1.1.0
type BrowseHandler struct {
// contains filtered or unexported fields
}
BrowseHandler is a http.Handler which will allow you to browse through artists or albums with the help of pagination.
func NewBrowseHandler ¶ added in v1.1.0
func NewBrowseHandler(lib library.Library) *BrowseHandler
NewBrowseHandler returns a new Browse handler. It needs a library to browse through.
func (BrowseHandler) ServeHTTP ¶ added in v1.1.0
func (bh BrowseHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP is required by the http.Handler's interface
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler will find and serve a media file by its ID
func NewFileHandler ¶
func NewFileHandler(lib library.Library) *FileHandler
NewFileHandler returns a new File handler will will be resposible for serving a file from the library identified from its ID.
func (FileHandler) ServeHTTP ¶
func (fh FileHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP is required by the http.Handler's interface
type GzipHandler ¶
type GzipHandler struct {
// contains filtered or unexported fields
}
GzipHandler gzips our output using a custom Writer. It will check if gzip is among the accepted encodings and gzip if so. Otherwise it will do nothing.
func (GzipHandler) ServeHTTP ¶
func (gzh GzipHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP satisfies the http.Handler interface
type SearchHandler ¶
type SearchHandler struct {
// contains filtered or unexported fields
}
SearchHandler is a http.Handler responsible for search requests. It will use the Library to return a list of matched files to the interface.
func NewSearchHandler ¶
func NewSearchHandler(lib library.Library) *SearchHandler
NewSearchHandler returns a new SearchHandler for processing search queries. They will be run against the supplied library
func (SearchHandler) ServeHTTP ¶
func (sh SearchHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP is required by the http.Handler's interface
type Server ¶
type Server struct {
// Makes the server lockable. This lock should be used for accessing the
// listener
sync.Mutex
// contains filtered or unexported fields
}
Server represends our webserver. It will be controlled from here
func NewServer ¶
NewServer Returns a new Server using the supplied configuration cfg. The returned server is ready and calling its Serve method will start it.
type TerryHandler ¶ added in v1.0.1
type TerryHandler struct {
// contains filtered or unexported fields
}
TerryHandler adds the X-Clacks-Overhead header. It wraps around the actual handler.
func (TerryHandler) ServeHTTP ¶ added in v1.0.1
func (th TerryHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)
ServeHTTP satisfies the http.Handler interface.