Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler holds dependencies for API handlers
func NewHandler ¶
func NewHandler(repo Repository, radio Radio, audioResolver audio.Resolver, c *cache.Cache) *Handler
NewHandler creates a new API handler
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers API routes on the given mux
type MoodInfo ¶
type MoodInfo struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
TrackCount int `json:"track_count"`
TotalMins float64 `json:"total_minutes"`
}
MoodInfo contains metadata about a mood
type PlaylistTrack ¶
type PlaylistTrack struct {
ID int64 `json:"id"`
FilePath string `json:"file_path"`
AudioURL string `json:"audio_url,omitempty"`
Title *string `json:"title,omitempty"`
Artist *string `json:"artist,omitempty"`
Energy string `json:"energy"`
Intensity *int `json:"intensity,omitempty"`
Lyrics *string `json:"lyrics,omitempty"`
}
PlaylistTrack is a slim view of a track for playlist responses. The frontend uses only these 8 fields; dropping the other 12 reduces payload size by ~60%.
type Radio ¶
type Radio interface {
GetPlaylist(mood string, instrumentalOnly bool) ([]*inventory.Track, error)
RecordPlay(mood string, trackID int64)
}
Radio provides playlist retrieval and play tracking
type Repository ¶
type Repository interface {
GetMoodStats() ([]inventory.MoodStats, error)
GetByID(id int64) (*inventory.Track, error)
BeginTx(ctx context.Context) (*sql.Tx, error)
UpdatePlayStatsTx(tx *sql.Tx, id int64) error
RecordListenEventTx(tx *sql.Tx, evt inventory.ListenEvent) error
}
Repository defines the data operations the handler needs
Click to show internal directories.
Click to hide internal directories.