SAVEPOINT

This commit is contained in:
luke.rodham
2017-11-10 10:52:11 +00:00
parent a189881568
commit 59301c7622
12 changed files with 455 additions and 7 deletions
+13 -1
View File
@@ -7,7 +7,8 @@ func NewRouter() *DefaultRouter {
}
type DefaultRouter struct {
Routes []*Route
Routes []*Route
StaticRoutes []*StaticRoute
}
func (r *DefaultRouter) GET(path string, h Handler) {
@@ -18,10 +19,21 @@ func (r *DefaultRouter) POST(path string, h Handler) {
r.addRoute(http.MethodPost, path, h)
}
func (r *DefaultRouter) Static(path string, root http.FileSystem) {
r.StaticRoutes = append(r.StaticRoutes, &StaticRoute{
Path: path,
Handler: http.StripPrefix(path, http.FileServer(root)),
})
}
func (r *DefaultRouter) GetRoutes() []*Route {
return r.Routes
}
func (r *DefaultRouter) GetStaticRoutes() []*StaticRoute {
return r.StaticRoutes
}
func (r *DefaultRouter) addRoute(m, p string, h Handler) {
r.Routes = append(r.Routes, &Route{
Method: m,