webserver

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2014 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

This module contains the webserver whcih deals with processing requests from the user, presenting him with the interface of the application.

Index

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)

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

func NewGzipHandler(handler http.Handler) http.Handler

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
}

Will find and serve a zip of the album by the album ID

func NewAlbumHandler

func NewAlbumHandler(lib library.Library) *AlbumHandler

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)

This method is required by the http.Handler's interface

type BasicAuthHandler

type BasicAuthHandler struct {
	// contains filtered or unexported fields
}

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)

Implements the http.Handler interface and does the actual basic authenticate check for every request

type FileHandler

type FileHandler struct {
	// contains filtered or unexported fields
}

Will find and serve a file by its ID

func NewFileHandler

func NewFileHandler(lib library.Library) *FileHandler

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)

This method is required by the http.Handler's interface

type GzipHandler

type GzipHandler struct {
	// contains filtered or unexported fields
}

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)

type SearchHandler

type SearchHandler struct {
	// contains filtered or unexported fields
}

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

Returns a new SearchHandler for processing search queries. They will be run agains the supplied library

func (SearchHandler) ServeHTTP

func (sh SearchHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request)

This method is required by the http.Handler's interface

type Server

type Server struct {
	// contains filtered or unexported fields
}

Represends our webserver. It will be controlled from here

func NewServer

func NewServer(cfg config.Config, lib library.Library) (srv *Server)

Returns a new Server using the supplied configuration cfg. The returned server is ready and calling its Serve method will start it.

func (*Server) Serve

func (srv *Server) Serve()

The function that actually starts the webserver. It attaches all the handlers and starts the webserver while consulting the ServerConfig supplied. Trying to call this method more than once for the same server will result in panic.

func (*Server) Stop

func (srv *Server) Stop()

Stops the webserver

func (*Server) Wait

func (srv *Server) Wait()

Syncs whoever called this with the server's stop

Jump to

Keyboard shortcuts

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