Skip to content
Snippets Groups Projects
Commit f62f333e authored by gjahn's avatar gjahn
Browse files

Set up routes can now return an error

This is to improve/funnel potentially fatal errors
parent 2fc512d1
No related branches found
No related tags found
No related merge requests found
......@@ -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 ) )
......
......@@ -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
}
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment