package main import ( "context" "log" "net/http" "os" "path" "uvok.de/go/training_fellow/registration" myhttp "uvok.de/go/training_fellow/registration/http" "uvok.de/go/training_fellow/registration/http/rest" "uvok.de/go/training_fellow/registration/nats" uvok_sqlite "uvok.de/go/training_fellow/registration/persistence/sqlite" ) func main() { log.Print("Starting application") workDir, err := os.Getwd() context := context.Background() if err != nil { workDir = "." } notifier := &nats.NatsNotifier{} databasePath := path.Join(workDir, "registrations.sqlite") repository := uvok_sqlite.NewRepository(databasePath, context) service := ®istration.RegistrationService{Notifier: notifier, Repository: repository} handler := &rest.RegistrationHandler{Service: service} newRegistrationHandler := rest.HandleRegistration(handler) contentHandler := myhttp.IsFormContentCheck(newRegistrationHandler) http.Handle("/register", contentHandler) http.Handle("/registrations", rest.HandleGetRegistrations(handler)) log.Print("Starting server") err = http.ListenAndServe(":8080", nil) if err != nil { log.Fatalf("Error starting HTTP server: %v", err) } }