feat: suit path

This commit is contained in:
tjq 2023-01-06 22:58:34 +08:00
parent 94a0e2fa42
commit d73b8e21e6
2 changed files with 17 additions and 2 deletions

View File

@ -61,8 +61,8 @@ class ActorFactory {
}
HandlerLocation handlerLocation = new HandlerLocation()
.setRootPath(rootPath)
.setMethodPath(handlerMethodAnnotation.path());
.setRootPath(suitPath(rootPath))
.setMethodPath(suitPath(handlerMethodAnnotation.path()));
HandlerInfo handlerInfo = new HandlerInfo()
.setAnno(handlerMethodAnnotation)
@ -72,4 +72,11 @@ class ActorFactory {
}
return ret;
}
static String suitPath(String path) {
if (path.startsWith("/")) {
return path.replaceFirst("/", "");
}
return path;
}
}

View File

@ -24,4 +24,12 @@ class ActorFactoryTest {
ActorFactory.load(Lists.newArrayList(new TestActor()));
}
@Test
void testSuitPath() {
final String testPath1 = ActorFactory.suitPath("/test");
final String testPath2 = ActorFactory.suitPath("test");
log.info("[ActorFactoryTest] testPath1: {}, testPath2: {}", testPath1, testPath2);
assert testPath1.equals(testPath2);
}
}