diff options
Diffstat (limited to '')
-rw-r--r-- | eg/base.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/eg/base.go b/eg/base.go deleted file mode 100644 index fdf2810..0000000 --- a/eg/base.go +++ /dev/null @@ -1,72 +0,0 @@ -package main - -import ( - "github.com/franckcuny/path-router" - "github.com/franckcuny/web-request" - "net/http" -) - -func TestId(req *request.Request) (request.Response, error) { - r := request.Response{ - Status: 200, - Content: "id", - } - return r, nil -} - -func TestIdFoo(req *request.Request) (request.Response, error) { - r := request.Response{ - Status: 200, - Content: "foo", - } - return r, nil -} - -func Test(req *request.Request) (request.Response, error) { - resp := request.Response{} - resp.Status = 200 - resp.Content = "duh" - return resp, nil -} - -func TestPut(req *request.Request) (request.Response, error) { - resp := request.Response{} - resp.Status = 200 - resp.Content = "ok" - return resp, nil -} - -func main() { - router := router.BuildRouter() - - router.AddRoute( - &router.Route{ - Method: "GET", - Path: "/foo/bar/baz", - Code: Test, - }, - ) - router.AddRoute( - &router.Route{ - Method: "PUT", - Path: "/foo/bar/baz", - Code: TestPut, - }, - ) - router.AddRoute( - &router.Route{ - Method: "GET", - Path: "/test/{id}", - Code: TestId, - }, - ) - router.AddRoute( - &router.Route{ - Method: "GET", - Path: "/test/{id}/foo", - Code: TestIdFoo, - }, - ) - - http.ListenAndServe(":8080", &router) -} |