Files
ozu.io/web/router.go
2016-07-11 01:19:21 +01:00

20 lines
484 B
Go

package web
import (
"github.com/jimeh/ozu.io/shortner"
"github.com/qiangxue/fasthttp-routing"
)
// NewRouter creates a new routing.Router with all handlers registered.
func NewRouter(shortner *shortner.Shortner) *routing.Router {
router := routing.New()
handlers := Handlers{shortner}
router.Get("/", handlers.Index)
router.Get("/api/shorten", handlers.Shorten)
router.Get("/api/lookup", handlers.Lookup)
router.Get("/<uid>", handlers.LookupAndRedirect)
return router
}