@Override public final <M> HtmlResponse render(String templatePath, M model) { String templateFullPath; if (StringUtils.startsWith(templatePath, "/")) { templateFullPath = templatePath; } else if (StringUtils.startsWith(templatePath, ".")) { templateFullPath = StrUtils.concatPath(templatesRootPath, templatePath.substring(1), "/"); } else { templateFullPath = StrUtils.concatPath(templatesRootPath, templatePath, "/"); } String html = doRender(templateFullPath, model); return new HtmlResponse(html); }
protected String buildMethodRoute(TeleMethodElement teleMethod) { AnnotationElement<Route> routeAnnotation = teleMethod.getProxyMethod().getOriginMethod().getAnnotation(Route.class); String methodRoute; if (routeAnnotation == null) { methodRoute = RouteTrie.SEGMENT_DELEMITER + StrUtils.toLowerCaseNotation(teleMethod.getName()); } else { methodRoute = routeAnnotation.unwrap().value(); } if (methodRoute.equals(RouteTrie.SEGMENT_DELEMITER)) { methodRoute = ""; } HttpMethod httpMethod = HttpMethod.GET; AnnotationElement<RequestMethod> methodAnnotation = teleMethod.getProxyMethod().getOriginMethod().getAnnotation(RequestMethod.class); if (methodAnnotation != null) { httpMethod = methodAnnotation.unwrap().value(); } String result = StrUtils.concatPath(httpMethod.name(), framletRoute, RouteTrie.SEGMENT_DELEMITER); result = StrUtils.concatPath(result, methodRoute, RouteTrie.SEGMENT_DELEMITER); return result; }
@Override public void perform(HttpMethod httpMethod, String uri) { RouteTrie.RouteResolution<TeleMethod> routeResolution = routeTrie.resolveRoute(StrUtils.concatPath(httpMethod.name(), uri, RouteTrie.SEGMENT_DELEMITER)); if (routeResolution == null) { throw new UnknownRouteException(uri, httpMethod); } TeleMethod telemethod = routeResolution.getNode().getValue(); if (telemethod == null) { throw new UnknownRouteException(uri, httpMethod); } RouterContext routerContext = new RouterContext(uri, routeResolution.getParams()); threadScope.put(RouterContext.SCOPE_KEY, routerContext); telemethod.invoke(); } }
beanRouteValue = "/"+ StrUtils.toLowerCaseNotation(classSimpleName); return StrUtils.concatPath(pkgRouteValue, beanRouteValue, RouteTrie.SEGMENT_DELEMITER); } else { throw CodegenException.of()