mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Update main.go according to latest changes
This commit is contained in:
19
main.go
19
main.go
@@ -7,9 +7,17 @@ import (
|
|||||||
"github.com/jimeh/ozu.io/shortener"
|
"github.com/jimeh/ozu.io/shortener"
|
||||||
"github.com/jimeh/ozu.io/storage/goleveldbstore"
|
"github.com/jimeh/ozu.io/storage/goleveldbstore"
|
||||||
"github.com/jimeh/ozu.io/web"
|
"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() {
|
func main() {
|
||||||
store, err := goleveldbstore.New("ozuio_database")
|
store, err := goleveldbstore.New("ozuio_database")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -18,12 +26,7 @@ func main() {
|
|||||||
defer store.Close()
|
defer store.Close()
|
||||||
|
|
||||||
s := shortener.New(store)
|
s := shortener.New(store)
|
||||||
router := web.NewRouter(s)
|
server := web.NewServer(s)
|
||||||
|
|
||||||
port := os.Getenv("PORT")
|
log.Fatal(server.ListenAndServe(":" + getPort()))
|
||||||
if port == "" {
|
|
||||||
port = "8080"
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Fatal(fasthttp.ListenAndServe(":"+port, router.HandleRequest))
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user