func main() { defer logger.Close() flag.Parse() logger.SetLevelThreshold(log.LogStringToLevel(*logLevelPtr)) logger.Debugf("set log level to %s", *logLevelPtr) writer := os.Stdout err := do(writer, *dbPathPtr) if err != nil { logger.Fatal(err) logger.Close() os.Exit(1) } }
func createServer(address string, documentRoot string, databaseName string, databaseUser string, databasePassword string, databaseLogging bool) *http.Server { logger.SetLevelThreshold(log.LogStringToLevel(*logLevelPtr)) logger.Debugf("set log level to %s", *logLevelPtr) db := booking_database_postgres.New(databaseName, databaseUser, databasePassword, databaseLogging) dateService := booking_date_service.New(booking_date_storage.New(db)) tokengenerator := booking_tokengenerator.New() modelService := booking_model_service.New(booking_model_storage.New(db), tokengenerator) eventbus := eventbus.New() shootingService := booking_shooting_service.New(booking_shooting_storage.New(db), eventbus) userService := booking_user_service.New(booking_user_storage.New(db)) authenticationService := booking_authentication_service.New(userService, modelService) authorizationService := booking_authorization_service.New() authenticationConverter := booking_authentication_converter.New() handlerConfiguration := booking_handler_configuration.New(documentRoot, dateService, modelService, shootingService, userService, authenticationService, authorizationService, authenticationConverter) return &http.Server{Addr: address, Handler: handlerConfiguration.GetHandler()} }
func createServer(address string, documentRoot string, dbPath string) *http.Server { logger.SetLevelThreshold(log.LogStringToLevel(*logLevelPtr)) logger.Debugf("set log level to %s", *logLevelPtr) return &http.Server{Addr: address, Handler: handler.NewHandler(documentRoot, dbPath)} }