Documentation ¶
Index ¶
- func BasicAuth(uss radio.UserStorageService) func(http.Handler) http.Handler
- func BasicAuthFailure(w http.ResponseWriter, r *http.Request)
- func GetTrack(ctx context.Context) (radio.Song, bool)
- func GetUser(ctx context.Context) (radio.User, bool)
- func InputMiddleware(cfg config.Config, status *util.Value[radio.Status]) func(http.Handler) http.Handler
- func NewSessionManager(ctx context.Context, storage radio.SessionStorageService) *scs.SessionManager
- func RequestWithUser(r *http.Request, u *radio.User) *http.Request
- func RequirePermission(perm radio.UserPermission, handler http.HandlerFunc) http.HandlerFunc
- func TrackCtx(storage radio.TrackStorageService) func(http.Handler) http.Handler
- func UserByDJIDCtx(storage radio.UserStorageService) func(http.Handler) http.Handler
- func UserFromContext(ctx context.Context) *radio.User
- type Authentication
- type Input
- type JSONCodec
- type LoginInput
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
BasicAuth lets users login through the HTTP Basic Authorization header
This should ONLY be used for situations where a human cannot input the login info somehow. Namely for icecast source clients.
func BasicAuthFailure ¶
func BasicAuthFailure(w http.ResponseWriter, r *http.Request)
BasicAuthFailure writes a http StatusUnauthorized response with extra text that some icecast source clients expect
func GetTrack ¶
GetTrack returns the track from the given context if one exists. See TrackCtx for supplier of this
func InputMiddleware ¶
func InputMiddleware(cfg config.Config, status *util.Value[radio.Status]) func(http.Handler) http.Handler
InputMiddleware generates an Input for each request and makes it available through InputFromRequest
func NewSessionManager ¶
func NewSessionManager(ctx context.Context, storage radio.SessionStorageService) *scs.SessionManager
func RequestWithUser ¶
RequestWithUser adds a user to a requests context and returns the new updated request after, user can be retrieved by UserFromContext
func RequirePermission ¶
func RequirePermission(perm radio.UserPermission, handler http.HandlerFunc) http.HandlerFunc
func TrackCtx ¶
TrackCtx reads an URL parameter named TrackID and tries to find the track associated with it.
func UserByDJIDCtx ¶
UserByDJIDCtx reads an URL router parameter named DJID and tries to find the user associated with it. The result can be retrieved with GetUser
Types ¶
type Authentication ¶
type Authentication interface { UserMiddleware(http.Handler) http.Handler LoginMiddleware(http.Handler) http.Handler GetLogin(http.ResponseWriter, *http.Request) PostLogin(http.ResponseWriter, *http.Request) LogoutHandler(http.ResponseWriter, *http.Request) }
func NewAuthentication ¶
func NewAuthentication(storage radio.StorageService, tmpl templates.Executor, sessions *scs.SessionManager) Authentication
type Input ¶
type Input struct { Now time.Time IsUser bool IsHTMX bool User *radio.User Status radio.Status StreamURL template.URL RequestURL template.URL }
Input is a bunch of data that should be accessable to the base template
func InputFromContext ¶
func InputFromRequest ¶
InputFromRequest returns the Input associated with the request
func (Input) TemplateName ¶
type JSONCodec ¶
type JSONCodec struct{}
JSONCodec implements scs.Codec
type LoginInput ¶
func NewLoginInput ¶
func NewLoginInput(r *http.Request, message string) LoginInput
func (LoginInput) TemplateBundle ¶
func (LoginInput) TemplateBundle() string
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore implements scs.Store by using a radio.SessionStorageService as its backing storage.
func NewSessionStore ¶
func NewSessionStore(ctx context.Context, storage radio.SessionStorageService) SessionStore
NewSessionStore returns a new SessionStore that uses the storage provided
func (SessionStore) Delete ¶
func (ss SessionStore) Delete(token string) error
Delete implements scs.Store