From 351be0b59d30cecf984d91fb7908d684ada9dc14 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 17 Jul 2016 16:18:01 +0100 Subject: [PATCH] Update main.go according to latest changes --- main.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index b3c056b..01ead81 100644 --- a/main.go +++ b/main.go @@ -7,9 +7,17 @@ import ( "github.com/jimeh/ozu.io/shortener" "github.com/jimeh/ozu.io/storage/goleveldbstore" "github.com/jimeh/ozu.io/web" - "github.com/valyala/fasthttp" ) +func getPort() string { + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } + + return port +} + func main() { store, err := goleveldbstore.New("ozuio_database") if err != nil { @@ -18,12 +26,7 @@ func main() { defer store.Close() s := shortener.New(store) - router := web.NewRouter(s) + server := web.NewServer(s) - port := os.Getenv("PORT") - if port == "" { - port = "8080" - } - - log.Fatal(fasthttp.ListenAndServe(":"+port, router.HandleRequest)) + log.Fatal(server.ListenAndServe(":" + getPort())) }