diff --git a/main.go b/main.go index f9bbd9f78a00de4da63c04585b73427bfc8a9ea9..3beb4aee8ef124d1c2e4e17f0b0aea2dbece2ee5 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,10 @@ func main() { var isHealthy = false - routing.SetRoutes( server, config, store, &isHealthy ) + err = routing.SetRoutes( server, config, store, &isHealthy ) + if err != nil { + log.Fatalf( "HTTP server failed to start: %v", err ) + } go func(){ err := server.Listen( fmt.Sprintf( "%s:%d", config.Host, config.Port ) ) diff --git a/routing/routes.go b/routing/routes.go index 0455c7677ac002c6e340d0cd7e765121575663c9..a9504cda2d90ab8603f060238ae65ba79146cdca 100644 --- a/routing/routes.go +++ b/routing/routes.go @@ -18,11 +18,11 @@ import ( ) -func SetRoutes( router *f.App, config *configuration.Config, store state.Store, healthiness *bool ) { +func SetRoutes( router *f.App, config *configuration.Config, store state.Store, healthiness *bool ) error { indexHtmlTemplate, err := template.New( "index" ).Parse( indexHtml ) if err != nil { - log.Fatal( err ) + return err } if config.LogLevel == "debug" { @@ -237,4 +237,7 @@ func SetRoutes( router *f.App, config *configuration.Config, store state.Store, router.Use( func( c *f.Ctx ) error { return c.SendStatus( http.StatusTeapot ) }) + + + return nil } diff --git a/routing/routes_test.go b/routing/routes_test.go index 5c9bfd87863d9ea65adcfc84a21678bb56fc59f5..c13d9a3f47488dbe6a0f726f69f6f16d9467ad71 100644 --- a/routing/routes_test.go +++ b/routing/routes_test.go @@ -32,7 +32,7 @@ func setup() ( *f.App, *configuration.Config, state.Store, *bool ){ }) store := state.NewEphemeralStore() var isHealthy = true - SetRoutes( server, config, store, &isHealthy ) + _ = SetRoutes( server, config, store, &isHealthy ) return server, config, store, &isHealthy }