Version: v0.0.0-...-60c60e4 Latest Latest

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

Go to latest
Published: Jun 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0



Package server implements the music server. It serves HTML pages and media files.



This section is empty.


This section is empty.


func HandleUnauthorized

func HandleUnauthorized(_ error) http.Handler

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.


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

type HTTPError struct {
	Code    int
	Message string
	// contains filtered or unexported fields

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

func NewBadRequestError(err error, message string) *HTTPError

NewBadRequestError creates a new HTTPError that will be converted to a 400 Bad Request error for end-users

func NewForbiddenError

func NewForbiddenError(err error) *HTTPError

NewForbiddenError creates a new HTTPError that will be converted to a 403 Forbidden error

func (*HTTPError) Error

func (h *HTTPError) Error() string

func (*HTTPError) Unwrap

func (h *HTTPError) Unwrap() error


Path Synopsis
Package app groups together app routes.
Package app groups together app routes.
Package user groups together user authentication code.
Package user groups together user authentication code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL