Update main.go according to latest changes

This commit is contained in:
2016-07-17 16:18:01 +01:00
parent 5d3c8ef3ca
commit 351be0b59d

19
main.go
View File

@@ -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()))
}