mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
30 lines
526 B
Go
30 lines
526 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/iris-contrib/middleware/logger"
|
|
"github.com/kataras/iris"
|
|
)
|
|
|
|
func main() {
|
|
shortner := NewShortner()
|
|
defer shortner.Close()
|
|
|
|
routes := Routes{Shortner: shortner}
|
|
|
|
iris.Use(logger.New(iris.Logger))
|
|
iris.Get("/set/:key/:value", routes.Set)
|
|
iris.Get("/get/:key", routes.Get)
|
|
iris.Get("/shorten/:url", routes.Shorten)
|
|
iris.Get("/lookup/:uid", routes.Lookup)
|
|
iris.Get("/", routes.Root)
|
|
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
iris.Listen(":" + port)
|
|
}
|