Skip to content

Commit 7487cf6

Browse files
author
yb-nuc
committed
routing bug fixed
1 parent 6e0e0af commit 7487cf6

File tree

17 files changed

+106
-41
lines changed

17 files changed

+106
-41
lines changed

CatLib.Unity/Assets/CatLib.Test/Editor/Core/EnvTests.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CatLib.Unity/Assets/CatLib.Test/Editor/Core/EventImplTests.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CatLib.Unity/Assets/CatLib.Test/Editor/Routing/AttrCompilerRouting.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CatLib.Unity/Assets/CatLib.Test/Editor/Routing/RouterExceptionTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class RouterExceptionTests
3535
internal Router MakeRouter()
3636
{
3737
var app = new CatLib.Core.Application();
38+
app.Bootstrap().Init();
3839
var router = new Router(app, app);
3940

4041
router.SetDefaultScheme("catlib");
@@ -187,7 +188,7 @@ public void TestNestedException()
187188
router.Dispatch("ui://helloworld/call3");
188189
}).OnError((req, res, ex ,next) =>
189190
{
190-
if (throwError == 0)
191+
if (throwError == 1)
191192
{
192193
throwError = 10;
193194
}
@@ -217,7 +218,7 @@ public void TestNestedException()
217218
router.Dispatch("ui://helloworld/call");
218219
});
219220

220-
Assert.AreEqual(11, throwError);
221+
Assert.AreEqual(12, throwError);
221222
Assert.AreEqual(0, throwNotFound);
222223
}
223224

@@ -237,7 +238,7 @@ public void TestNestedExceptionInterception()
237238
router.Dispatch("ui://helloworld/call3");
238239
}).OnError((req, res, ex, next) =>
239240
{
240-
if (throwError == 0)
241+
if (throwError == 1)
241242
{
242243
throwError = 10;
243244
}

CatLib.Unity/Assets/CatLib.Test/Editor/Routing/RouterExceptionTests.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CatLib.Unity/Assets/CatLib.Test/Editor/Routing/RouterTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,5 +547,22 @@ public void TestUseGroupAndLocalDefaults()
547547
var response = router.Dispatch("routed://use-group-and-local-defaults");
548548
Assert.AreEqual("hello world[global middleware]", response.GetContext());
549549
}
550+
551+
[TestMethod]
552+
public void TestClassMiddlewareThenRouteMiddleware()
553+
{
554+
var router = App.Instance.Make<IRouter>();
555+
556+
router.Group("RoutingMiddleware.ClassMiddlewareThenRouteMiddleTest")
557+
.Middleware((req, res, next) =>
558+
{
559+
next(req, res);
560+
res.SetContext(res.GetContext() + "[middleware with route group]");
561+
});
562+
563+
var response = router.Dispatch("rm://class-middleware-then-route-middle-test");
564+
565+
Assert.AreEqual("ClassMiddlewareThenRouteMiddleTest[middleware with route group][with middleware][global middleware]", response.GetContext());
566+
}
550567
}
551568
}

CatLib.Unity/Assets/CatLib.Test/Editor/Routing/RoutingMiddleware.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,11 @@ public void Call(IRequest request, IResponse response)
4040
{
4141
response.SetContext("RoutingMiddleware.Call");
4242
}
43+
44+
[Routed(Group = "RoutingMiddleware.ClassMiddlewareThenRouteMiddleTest")]
45+
public void ClassMiddlewareThenRouteMiddleTest(IRequest request, IResponse response)
46+
{
47+
response.SetContext("ClassMiddlewareThenRouteMiddleTest");
48+
}
4349
}
4450
}
512 Bytes
Binary file not shown.
75 Bytes
Binary file not shown.

CatLib.Unity/Assets/CatLib/Lib/CatLib.dll.mdb.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)