package morningalarm import ( "github.com/gin-gonic/gin" "github.com/robfig/cron/v3" "github.com/zmb3/spotify/v2" ) type alarm struct { Name string `json:"name" binding:"required"` Time string `json:"time" binding:"required"` id cron.EntryID } type MorningAlarmConfig struct { DeviceName string `json:"deviceName"` PlaylistID string `json:"wakeupContext"` ListenAddr string `json:"listenAddr"` OAuthProxyURL string `json:"oauthProxyUrl"` OAuthProxyAPIKey string `json:"oauthProxyApiKey"` } type MorningAlarm struct { config MorningAlarmConfig sp *spotify.Client cr *cron.Cron ro *gin.Engine alarms []alarm } func New(config MorningAlarmConfig) *MorningAlarm { return &MorningAlarm{ config: config, } } func (ma *MorningAlarm) Start() { ma.cr = cron.New() ma.loadAlarms() ma.cr.Start() ma.ro = gin.Default() ma.setupSpotifyWithProxy() ma.setupWebserver() ma.ro.Run(ma.config.ListenAddr) }