mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
24 lines
524 B
Go
24 lines
524 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()
|
|
|
|
api := NewAPIHandler(s)
|
|
r.Get("/api/shorten", api.Shorten)
|
|
r.Get("/api/lookup", api.Lookup)
|
|
|
|
handler := NewHandler(s)
|
|
r.Get("/", handler.Index)
|
|
r.Get("/static/*", handler.Static)
|
|
r.Get("/<uid>", handler.LookupAndRedirect)
|
|
r.Get("/*", handler.NotFound)
|
|
|
|
return r
|
|
}
|