mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
Add MBID
Add ability to set custom port
This commit is contained in:
parent
a22f282a6d
commit
08f0cb6c80
5 changed files with 26 additions and 5 deletions
|
@ -48,6 +48,7 @@ func CloseDbConn() {
|
|||
}
|
||||
|
||||
func runMigrations() {
|
||||
fmt.Println("Checking database migrations")
|
||||
driver, err := mysql.WithInstance(db, &mysql.Config{})
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to run migrations! %v", err)
|
||||
|
@ -66,11 +67,14 @@ func runMigrations() {
|
|||
if err != nil {
|
||||
// Skip 'no change'. This is fine. Everything is fine.
|
||||
if err.Error() == "no change" {
|
||||
fmt.Println("Database already up to date")
|
||||
return
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("Error running DB Migrations %v", err))
|
||||
}
|
||||
|
||||
fmt.Println("Database migrations complete")
|
||||
}
|
||||
|
||||
func getDbCount(query string, args ...interface{}) (int, error) {
|
||||
|
|
|
@ -38,7 +38,7 @@ func enableCors(w *http.ResponseWriter) {
|
|||
}
|
||||
|
||||
// HandleRequests - Boot HTTP!
|
||||
func HandleRequests() {
|
||||
func HandleRequests(port string) {
|
||||
// Create a new router
|
||||
r := mux.NewRouter().StrictSlash(true)
|
||||
|
||||
|
@ -70,7 +70,8 @@ func HandleRequests() {
|
|||
handler := c.Handler(r)
|
||||
|
||||
// Serve it up!
|
||||
log.Fatal(http.ListenAndServe(":42069", handler))
|
||||
fmt.Printf("Goscrobble listening on port %s", port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, handler))
|
||||
}
|
||||
|
||||
// MIDDLEWARE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue