added migrations back + removed distracting log message
This commit is contained in:
@@ -25,7 +25,6 @@ func OpenDatabase() (models.IDatabase, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Migrate() error {
|
func Migrate() error {
|
||||||
return nil
|
|
||||||
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
||||||
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
|
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
|
||||||
// dbUser := helper.GetEnv("POSTGRES_USER", "api_nutzer")
|
// dbUser := helper.GetEnv("POSTGRES_USER", "api_nutzer")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"arbeitszeitmessung/helper"
|
"arbeitszeitmessung/helper"
|
||||||
"arbeitszeitmessung/models"
|
"arbeitszeitmessung/models"
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -47,6 +48,8 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer models.DB.(*sql.DB).Close()
|
||||||
|
|
||||||
err = Migrate()
|
err = Migrate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to migrate the database to newest version", "Error", err)
|
slog.Error("Failed to migrate the database to newest version", "Error", err)
|
||||||
@@ -86,7 +89,9 @@ func ParamsMiddleware(next http.HandlerFunc) http.Handler {
|
|||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
queryParams := r.URL.Query()
|
queryParams := r.URL.Query()
|
||||||
ctx := context.WithValue(r.Context(), "urlParams", queryParams)
|
ctx := context.WithValue(r.Context(), "urlParams", queryParams)
|
||||||
|
if len(queryParams) > 0 {
|
||||||
slog.Debug("ParamsMiddleware added urlParams", slog.Any("urlParams", queryParams))
|
slog.Debug("ParamsMiddleware added urlParams", slog.Any("urlParams", queryParams))
|
||||||
|
}
|
||||||
next.ServeHTTP(w, r.WithContext(ctx))
|
next.ServeHTTP(w, r.WithContext(ctx))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user