Данные от ластфм вынесены в конфиг

design
serr 2025-05-18 14:11:59 +03:00
parent 4e2f70668d
commit b28d08f95e
2 changed files with 13 additions and 11 deletions

View File

@ -12,7 +12,7 @@ func LastfmHandler(app *models.App) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var err error var err error
resp, err := models.GetRecentTracks("s3rr", "bc5ce9ff9289ac925841cf483e211fc1") resp, err := models.GetRecentTracks(app.Cfg.LastfmUsername, app.Cfg.LastfmToken)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }

View File

@ -10,16 +10,18 @@ const (
) )
type Config struct { type Config struct {
PostsDir string PostsDir string
AssetsDir string AssetsDir string
TemplatesDir string TemplatesDir string
TemplatesExt string TemplatesExt string
LocalIP string LocalIP string
LocalPort string LocalPort string
ServerIP string ServerIP string
ServerPort string ServerPort string
ServerDomain string ServerDomain string
Port string Port string
LastfmUsername string
LastfmToken string
} }
func loadConfig(configPath string) (*Config, error) { func loadConfig(configPath string) (*Config, error) {