|
@ -75,7 +75,7 @@ func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { |
|
|
w.Write([]byte("Not Found: " + req.URL.Path)) |
|
|
w.Write([]byte("Not Found: " + req.URL.Path)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (router *Router) Resource(mount string, list, create Func, get, update, delete IDFunc) { |
|
|
|
|
|
|
|
|
func (router *Router) Resource(mount string, list, create ResourceFunc, get, update, delete ResourceIDFunc) { |
|
|
router.Route(mount, NewResource(list, create, get, update, delete)) |
|
|
router.Route(mount, NewResource(list, create, get, update, delete)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -83,6 +83,10 @@ func (router *Router) Static(mount string, filePath string) { |
|
|
router.Route(mount, NewStatic(filePath)) |
|
|
router.Route(mount, NewStatic(filePath)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (router *Router) Function(mount string, function FunctionHandlerFunc) { |
|
|
|
|
|
router.Route(mount, &functionHandler{function}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (router *Router) Listen(host string, port int) (*http.Server, error) { |
|
|
func (router *Router) Listen(host string, port int) (*http.Server, error) { |
|
|
srv := &http.Server{ |
|
|
srv := &http.Server{ |
|
|
Addr: fmt.Sprintf("%s:%d", host, port), |
|
|
Addr: fmt.Sprintf("%s:%d", host, port), |
|
|