1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 03:47:04 +00:00
This commit is contained in:
Makis Maropoulos
2016-06-18 01:14:57 +03:00
parent 5060cf4f5e
commit a245a19d02
4 changed files with 44 additions and 44 deletions

View File

@@ -27,33 +27,33 @@ type route struct {
var routes = []route{
// FOUND - registed
route{"GET", "/test_get", "/test_get", "hello, get!", 200, true, nil, nil},
route{"POST", "/test_post", "/test_post", "hello, post!", 200, true, nil, nil},
route{"PUT", "/test_put", "/test_put", "hello, put!", 200, true, nil, nil},
route{"DELETE", "/test_delete", "/test_delete", "hello, delete!", 200, true, nil, nil},
route{"HEAD", "/test_head", "/test_head", "hello, head!", 200, true, nil, nil},
route{"OPTIONS", "/test_options", "/test_options", "hello, options!", 200, true, nil, nil},
route{"CONNECT", "/test_connect", "/test_connect", "hello, connect!", 200, true, nil, nil},
route{"PATCH", "/test_patch", "/test_patch", "hello, patch!", 200, true, nil, nil},
route{"TRACE", "/test_trace", "/test_trace", "hello, trace!", 200, true, nil, nil},
{"GET", "/test_get", "/test_get", "hello, get!", 200, true, nil, nil},
{"POST", "/test_post", "/test_post", "hello, post!", 200, true, nil, nil},
{"PUT", "/test_put", "/test_put", "hello, put!", 200, true, nil, nil},
{"DELETE", "/test_delete", "/test_delete", "hello, delete!", 200, true, nil, nil},
{"HEAD", "/test_head", "/test_head", "hello, head!", 200, true, nil, nil},
{"OPTIONS", "/test_options", "/test_options", "hello, options!", 200, true, nil, nil},
{"CONNECT", "/test_connect", "/test_connect", "hello, connect!", 200, true, nil, nil},
{"PATCH", "/test_patch", "/test_patch", "hello, patch!", 200, true, nil, nil},
{"TRACE", "/test_trace", "/test_trace", "hello, trace!", 200, true, nil, nil},
// NOT FOUND - not registed
route{"GET", "/test_get_nofound", "/test_get_nofound", "Not Found", 404, false, nil, nil},
route{"POST", "/test_post_nofound", "/test_post_nofound", "Not Found", 404, false, nil, nil},
route{"PUT", "/test_put_nofound", "/test_put_nofound", "Not Found", 404, false, nil, nil},
route{"DELETE", "/test_delete_nofound", "/test_delete_nofound", "Not Found", 404, false, nil, nil},
route{"HEAD", "/test_head_nofound", "/test_head_nofound", "Not Found", 404, false, nil, nil},
route{"OPTIONS", "/test_options_nofound", "/test_options_nofound", "Not Found", 404, false, nil, nil},
route{"CONNECT", "/test_connect_nofound", "/test_connect_nofound", "Not Found", 404, false, nil, nil},
route{"PATCH", "/test_patch_nofound", "/test_patch_nofound", "Not Found", 404, false, nil, nil},
route{"TRACE", "/test_trace_nofound", "/test_trace_nofound", "Not Found", 404, false, nil, nil},
{"GET", "/test_get_nofound", "/test_get_nofound", "Not Found", 404, false, nil, nil},
{"POST", "/test_post_nofound", "/test_post_nofound", "Not Found", 404, false, nil, nil},
{"PUT", "/test_put_nofound", "/test_put_nofound", "Not Found", 404, false, nil, nil},
{"DELETE", "/test_delete_nofound", "/test_delete_nofound", "Not Found", 404, false, nil, nil},
{"HEAD", "/test_head_nofound", "/test_head_nofound", "Not Found", 404, false, nil, nil},
{"OPTIONS", "/test_options_nofound", "/test_options_nofound", "Not Found", 404, false, nil, nil},
{"CONNECT", "/test_connect_nofound", "/test_connect_nofound", "Not Found", 404, false, nil, nil},
{"PATCH", "/test_patch_nofound", "/test_patch_nofound", "Not Found", 404, false, nil, nil},
{"TRACE", "/test_trace_nofound", "/test_trace_nofound", "Not Found", 404, false, nil, nil},
// Parameters
route{"GET", "/test_get_parameter1/:name", "/test_get_parameter1/iris", "name=iris", 200, true, []param{param{"name", "iris"}}, nil},
route{"GET", "/test_get_parameter2/:name/details/:something", "/test_get_parameter2/iris/details/anything", "name=iris,something=anything", 200, true, []param{param{"name", "iris"}, param{"something", "anything"}}, nil},
route{"GET", "/test_get_parameter2/:name/details/:something/*else", "/test_get_parameter2/iris/details/anything/elsehere", "name=iris,something=anything,else=/elsehere", 200, true, []param{param{"name", "iris"}, param{"something", "anything"}, param{"else", "elsehere"}}, nil},
{"GET", "/test_get_parameter1/:name", "/test_get_parameter1/iris", "name=iris", 200, true, []param{{"name", "iris"}}, nil},
{"GET", "/test_get_parameter2/:name/details/:something", "/test_get_parameter2/iris/details/anything", "name=iris,something=anything", 200, true, []param{{"name", "iris"}, {"something", "anything"}}, nil},
{"GET", "/test_get_parameter2/:name/details/:something/*else", "/test_get_parameter2/iris/details/anything/elsehere", "name=iris,something=anything,else=/elsehere", 200, true, []param{{"name", "iris"}, {"something", "anything"}, {"else", "elsehere"}}, nil},
// URL Parameters
route{"GET", "/test_get_urlparameter1/first", "/test_get_urlparameter1/first?name=irisurl", "name=irisurl", 200, true, nil, []param{param{"name", "irisurl"}}},
route{"GET", "/test_get_urlparameter2/second", "/test_get_urlparameter2/second?name=irisurl&something=anything", "name=irisurl,something=anything", 200, true, nil, []param{param{"name", "irisurl"}, param{"something", "anything"}}},
route{"GET", "/test_get_urlparameter2/first/second/third", "/test_get_urlparameter2/first/second/third?name=irisurl&something=anything&else=elsehere", "name=irisurl,something=anything,else=elsehere", 200, true, nil, []param{param{"name", "irisurl"}, param{"something", "anything"}, param{"else", "elsehere"}}},
{"GET", "/test_get_urlparameter1/first", "/test_get_urlparameter1/first?name=irisurl", "name=irisurl", 200, true, nil, []param{{"name", "irisurl"}}},
{"GET", "/test_get_urlparameter2/second", "/test_get_urlparameter2/second?name=irisurl&something=anything", "name=irisurl,something=anything", 200, true, nil, []param{{"name", "irisurl"}, {"something", "anything"}}},
{"GET", "/test_get_urlparameter2/first/second/third", "/test_get_urlparameter2/first/second/third?name=irisurl&something=anything&else=elsehere", "name=irisurl,something=anything,else=elsehere", 200, true, nil, []param{{"name", "irisurl"}, {"something", "anything"}, {"else", "elsehere"}}},
}
func TestRouter(t *testing.T) {