mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Get basic HTTP server working
This commit is contained in:
12
main.go
12
main.go
@@ -1,12 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/jimeh/ozu.io/shortner"
|
||||
"github.com/jimeh/ozu.io/storage/goleveldbstore"
|
||||
"github.com/jimeh/ozu.io/web"
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -14,8 +15,15 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
shortner := shortner.New(store)
|
||||
router := web.NewRouter(shortner)
|
||||
fmt.Println(router)
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
}
|
||||
|
||||
log.Fatal(fasthttp.ListenAndServe(":"+port, router.HandleRequest))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user