mirror of
https://github.com/cubixle/tuu.git
synced 2026-04-24 23:04:43 +01:00
SAVEPOINT
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package tuu
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NewRouter() *DefaultRouter {
|
||||
return &DefaultRouter{}
|
||||
@@ -9,6 +13,12 @@ func NewRouter() *DefaultRouter {
|
||||
type DefaultRouter struct {
|
||||
Routes []*Route
|
||||
StaticRoutes []*StaticRoute
|
||||
|
||||
prefix string
|
||||
}
|
||||
|
||||
func (r *Prefix) Prefix(path string) {
|
||||
r.prefix = path
|
||||
}
|
||||
|
||||
func (r *DefaultRouter) GET(path string, h Handler) {
|
||||
@@ -26,6 +36,10 @@ func (r *DefaultRouter) Static(path string, root http.FileSystem) {
|
||||
})
|
||||
}
|
||||
|
||||
func (r *DefaultRouter) NotFound(path string, h Handler) {
|
||||
|
||||
}
|
||||
|
||||
func (r *DefaultRouter) GetRoutes() []*Route {
|
||||
return r.Routes
|
||||
}
|
||||
@@ -35,9 +49,11 @@ func (r *DefaultRouter) GetStaticRoutes() []*StaticRoute {
|
||||
}
|
||||
|
||||
func (r *DefaultRouter) addRoute(m, p string, h Handler) {
|
||||
path := fmt.Sprintf("/%s/%s", strings.TrimPrefix(r.prefix, "/"), strings.TrimSuffix(p, "/"))
|
||||
|
||||
r.Routes = append(r.Routes, &Route{
|
||||
Method: m,
|
||||
Path: p,
|
||||
Path: path,
|
||||
Handler: h,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user