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