Files
ozu.io/web/router.go
Jim Myhrberg 68807898da Lots of changes to web package
Use go-bindata, html/templates, and lots of other changes to the web
package.
2016-07-17 16:16:59 +01:00

22 lines
464 B
Go

package web
import (
"github.com/jimeh/ozu.io/shortener"
"github.com/qiangxue/fasthttp-routing"
)
// NewRouter creates a new routing.Router with all handlers registered.
func NewRouter(s shortener.Shortener) *routing.Router {
r := routing.New()
h := NewHandler(s)
r.Get("/", h.Index)
r.Get("/api/shorten", h.Shorten)
r.Get("/api/lookup", h.Lookup)
r.Get("/static/*", h.Static)
r.Get("/<uid>", h.LookupAndRedirect)
r.Get("/*", h.NotFound)
return r
}