package main import ( "github.com/gin-gonic/gin" "os" "log/slog" ) // Grab some required spotify credentials from the environment var spotifyClientID = os.Getenv("SPOTIFY_ID") var spotifyClientSecret = os.Getenv("SPOTIFY_SECRET") // Make sure the DB is in a good state to launch var db = setupDatabase() func setupRouter() *gin.Engine { var r *gin.Engine = gin.Default() // Add middleware to handle spotify auth for us r.Use(spotifyAuth(spotifyClientID, spotifyClientSecret)) r.GET("/ping", ping) r.GET("/artists/:artistID", getArtistByID) return r } func main() { // If the auth/ID variables are empty something is probably misconfigured if spotifyClientID == "" { slog.Warn("[GOMUSIC] No Spotify ID configured in 'SPOTIFY_ID' environment variable") } if spotifyClientSecret == "" { slog.Warn("[GOMUSIC] No Spotify secret configured in 'SPOTIFY_SECRET' environment variable") } // Router and server setup r := setupRouter() r.Run(":8080") }