Documentation ¶
Overview ¶
Package server implements the music server. It serves HTML pages and media files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleUnauthorized ¶
HandleUnauthorized redirects to /sign-in when users are not authenticated. It is used by sessionup's Auth middleware.
func Register ¶
func Register( router *mux.Router, sessionManager *sessionup.Manager, assetsLoader adapter.PathJoiner, musicLoader adapter.PathJoiner, )
Register registers routes for the assets and music routes on the given gorilla/mux router.
func WrapErrors ¶
func WrapErrors(next ErroringHandler) http.Handler
WrapErrors wraps ErroringHandler, catches the error returned from its ServeHTTP function and outputs a 500 Internal Server Error to the user with it.
Types ¶
type ErroringHandler ¶
type ErroringHandler interface {
ServeHTTP(writer http.ResponseWriter, request *http.Request) error
}
ErroringHandler is a http.Handler that can return an error. If the error is a HTTPError, its Code and Message will be used in the response. If the error is not nil, it will be output as a 500 Internal Server Error.
type HTTPError ¶
HTTPError is an error wrapper for errors that must be converted to HTTP errors. Code must be an HTTP Status code. Message is the string that will be shown to end-users. err is the underlying error. It is not displayed to end-users but will be logged.
func NewBadRequestError ¶
NewBadRequestError creates a new HTTPError that will be converted to a 400 Bad Request error for end-users
func NewForbiddenError ¶
NewForbiddenError creates a new HTTPError that will be converted to a 403 Forbidden error