mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
gofmt
This commit is contained in:
parent
5060cf4f5e
commit
a245a19d02
|
@ -238,7 +238,7 @@ func (srv *Server) interruptChan() chan os.Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) handleInterrupt(interrupt chan os.Signal, quitting chan struct{}, listener net.Listener) {
|
func (srv *Server) handleInterrupt(interrupt chan os.Signal, quitting chan struct{}, listener net.Listener) {
|
||||||
for _ = range interrupt {
|
for range interrupt {
|
||||||
if srv.Interrupted {
|
if srv.Interrupted {
|
||||||
srv.log("already shutting down")
|
srv.log("already shutting down")
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -176,7 +176,7 @@ func New(options Options) *Cors {
|
||||||
break
|
break
|
||||||
} else if i := strings.IndexByte(origin, '*'); i >= 0 {
|
} else if i := strings.IndexByte(origin, '*'); i >= 0 {
|
||||||
// Split the origin in two: start and end string without the *
|
// Split the origin in two: start and end string without the *
|
||||||
w := wildcard{origin[0:i], origin[i+1 : len(origin)]}
|
w := wildcard{origin[0:i], origin[i+1:]}
|
||||||
c.allowedWOrigins = append(c.allowedWOrigins, w)
|
c.allowedWOrigins = append(c.allowedWOrigins, w)
|
||||||
} else {
|
} else {
|
||||||
c.allowedOrigins = append(c.allowedOrigins, origin)
|
c.allowedOrigins = append(c.allowedOrigins, origin)
|
||||||
|
|
|
@ -13,25 +13,25 @@ var internalServerMessage = "Iris custom message for 500 internal server error"
|
||||||
|
|
||||||
var routesCustomErrors = []route{
|
var routesCustomErrors = []route{
|
||||||
// NOT FOUND CUSTOM ERRORS - not registed
|
// NOT FOUND CUSTOM ERRORS - not registed
|
||||||
route{"GET", "/test_get_nofound_custom", "/test_get_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"GET", "/test_get_nofound_custom", "/test_get_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"POST", "/test_post_nofound_custom", "/test_post_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"POST", "/test_post_nofound_custom", "/test_post_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"PUT", "/test_put_nofound_custom", "/test_put_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"PUT", "/test_put_nofound_custom", "/test_put_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"DELETE", "/test_delete_nofound_custom", "/test_delete_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"DELETE", "/test_delete_nofound_custom", "/test_delete_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"HEAD", "/test_head_nofound_custom", "/test_head_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"HEAD", "/test_head_nofound_custom", "/test_head_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"OPTIONS", "/test_options_nofound_custom", "/test_options_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"OPTIONS", "/test_options_nofound_custom", "/test_options_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"CONNECT", "/test_connect_nofound_custom", "/test_connect_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"CONNECT", "/test_connect_nofound_custom", "/test_connect_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"PATCH", "/test_patch_nofound_custom", "/test_patch_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"PATCH", "/test_patch_nofound_custom", "/test_patch_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
route{"TRACE", "/test_trace_nofound_custom", "/test_trace_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
{"TRACE", "/test_trace_nofound_custom", "/test_trace_nofound_custom", notFoundMessage, 404, false, nil, nil},
|
||||||
// SERVER INTERNAL ERROR 500 PANIC CUSTOM ERRORS - registed
|
// SERVER INTERNAL ERROR 500 PANIC CUSTOM ERRORS - registed
|
||||||
route{"GET", "/test_get_panic_custom", "/test_get_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"GET", "/test_get_panic_custom", "/test_get_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"POST", "/test_post_panic_custom", "/test_post_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"POST", "/test_post_panic_custom", "/test_post_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"PUT", "/test_put_panic_custom", "/test_put_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"PUT", "/test_put_panic_custom", "/test_put_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"DELETE", "/test_delete_panic_custom", "/test_delete_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"DELETE", "/test_delete_panic_custom", "/test_delete_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"HEAD", "/test_head_panic_custom", "/test_head_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"HEAD", "/test_head_panic_custom", "/test_head_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"OPTIONS", "/test_options_panic_custom", "/test_options_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"OPTIONS", "/test_options_panic_custom", "/test_options_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"CONNECT", "/test_connect_panic_custom", "/test_connect_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"CONNECT", "/test_connect_panic_custom", "/test_connect_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"PATCH", "/test_patch_panic_custom", "/test_patch_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"PATCH", "/test_patch_panic_custom", "/test_patch_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
route{"TRACE", "/test_trace_panic_custom", "/test_trace_panic_custom", internalServerMessage, 500, true, nil, nil},
|
{"TRACE", "/test_trace_panic_custom", "/test_trace_panic_custom", internalServerMessage, 500, true, nil, nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCustomErrors(t *testing.T) {
|
func TestCustomErrors(t *testing.T) {
|
||||||
|
|
|
@ -27,33 +27,33 @@ type route struct {
|
||||||
|
|
||||||
var routes = []route{
|
var routes = []route{
|
||||||
// FOUND - registed
|
// FOUND - registed
|
||||||
route{"GET", "/test_get", "/test_get", "hello, get!", 200, true, nil, nil},
|
{"GET", "/test_get", "/test_get", "hello, get!", 200, true, nil, nil},
|
||||||
route{"POST", "/test_post", "/test_post", "hello, post!", 200, true, nil, nil},
|
{"POST", "/test_post", "/test_post", "hello, post!", 200, true, nil, nil},
|
||||||
route{"PUT", "/test_put", "/test_put", "hello, put!", 200, true, nil, nil},
|
{"PUT", "/test_put", "/test_put", "hello, put!", 200, true, nil, nil},
|
||||||
route{"DELETE", "/test_delete", "/test_delete", "hello, delete!", 200, true, nil, nil},
|
{"DELETE", "/test_delete", "/test_delete", "hello, delete!", 200, true, nil, nil},
|
||||||
route{"HEAD", "/test_head", "/test_head", "hello, head!", 200, true, nil, nil},
|
{"HEAD", "/test_head", "/test_head", "hello, head!", 200, true, nil, nil},
|
||||||
route{"OPTIONS", "/test_options", "/test_options", "hello, options!", 200, true, nil, nil},
|
{"OPTIONS", "/test_options", "/test_options", "hello, options!", 200, true, nil, nil},
|
||||||
route{"CONNECT", "/test_connect", "/test_connect", "hello, connect!", 200, true, nil, nil},
|
{"CONNECT", "/test_connect", "/test_connect", "hello, connect!", 200, true, nil, nil},
|
||||||
route{"PATCH", "/test_patch", "/test_patch", "hello, patch!", 200, true, nil, nil},
|
{"PATCH", "/test_patch", "/test_patch", "hello, patch!", 200, true, nil, nil},
|
||||||
route{"TRACE", "/test_trace", "/test_trace", "hello, trace!", 200, true, nil, nil},
|
{"TRACE", "/test_trace", "/test_trace", "hello, trace!", 200, true, nil, nil},
|
||||||
// NOT FOUND - not registed
|
// NOT FOUND - not registed
|
||||||
route{"GET", "/test_get_nofound", "/test_get_nofound", "Not Found", 404, false, nil, nil},
|
{"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},
|
{"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},
|
{"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},
|
{"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},
|
{"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},
|
{"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},
|
{"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},
|
{"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},
|
{"TRACE", "/test_trace_nofound", "/test_trace_nofound", "Not Found", 404, false, nil, nil},
|
||||||
// Parameters
|
// Parameters
|
||||||
route{"GET", "/test_get_parameter1/:name", "/test_get_parameter1/iris", "name=iris", 200, true, []param{param{"name", "iris"}}, nil},
|
{"GET", "/test_get_parameter1/:name", "/test_get_parameter1/iris", "name=iris", 200, true, []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},
|
{"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},
|
||||||
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_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
|
// URL Parameters
|
||||||
route{"GET", "/test_get_urlparameter1/first", "/test_get_urlparameter1/first?name=irisurl", "name=irisurl", 200, true, nil, []param{param{"name", "irisurl"}}},
|
{"GET", "/test_get_urlparameter1/first", "/test_get_urlparameter1/first?name=irisurl", "name=irisurl", 200, true, nil, []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"}}},
|
{"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"}}},
|
||||||
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_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) {
|
func TestRouter(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user