Search in sources :

Example 1 with UrlPath

use of org.webpieces.router.impl.UrlPath in project webpieces by deanhiller.

the class AbstractRouteBuilder method addContentRoute.

public void addContentRoute(HttpMethod method, String path, String controllerMethod) {
    UrlPath p = new UrlPath(routerInfo, path);
    Route route = new RouteImpl(method, p, controllerMethod, isHttpsOnlyRoutes);
    addRoute(route, null);
}
Also used : RouteImpl(org.webpieces.router.impl.RouteImpl) UrlPath(org.webpieces.router.impl.UrlPath) Route(org.webpieces.router.impl.Route) MultiRoute(org.webpieces.router.api.routing.MultiRoute)

Example 2 with UrlPath

use of org.webpieces.router.impl.UrlPath in project webpieces by deanhiller.

the class R1RouterBuilder method addStaticRoute.

private void addStaticRoute(String urlPath, String fileSystemPath, boolean isOnClassPath) {
    if (isOnClassPath)
        throw new UnsupportedOperationException("oops, isOnClassPath not supported yet");
    StaticRoute route = new StaticRoute(new UrlPath(routerInfo, urlPath), fileSystemPath, isOnClassPath, holder.getCachedCompressedDirectory());
    staticRoutes.add(route);
    log.info("scope:'" + routerInfo + "' adding static route=" + route.getFullPath() + " fileSystemPath=" + route.getFileSystemPath());
    RouteMeta meta = new RouteMeta(route, holder.getInjector(), currentPackage.get(), holder.getUrlEncoding());
    allRouting.addStaticRoute(meta);
}
Also used : StaticRoute(org.webpieces.router.impl.StaticRoute) RouteMeta(org.webpieces.router.impl.RouteMeta) UrlPath(org.webpieces.router.impl.UrlPath)

Example 3 with UrlPath

use of org.webpieces.router.impl.UrlPath in project webpieces by deanhiller.

the class TestCompressionCache method runBasicServerOnce.

private List<StaticRoute> runBasicServerOnce(File stagingDir) {
    List<StaticRoute> routes = new ArrayList<>();
    routes.add(new StaticRoute(new UrlPath("", "/public/"), stagingDir.getAbsolutePath() + "/", false, cacheDir));
    cache.setupCache(routes);
    Assert.assertEquals(2, proxy.getReadFiles().size());
    Assert.assertEquals(2, proxy.getCompressedFiles().size());
    proxy.clear();
    return routes;
}
Also used : StaticRoute(org.webpieces.router.impl.StaticRoute) UrlPath(org.webpieces.router.impl.UrlPath) ArrayList(java.util.ArrayList)

Example 4 with UrlPath

use of org.webpieces.router.impl.UrlPath in project webpieces by deanhiller.

the class AbstractRouteBuilder method addRoute.

@Override
public void addRoute(HttpMethod method, String path, String controllerMethod, RouteId routeId, boolean checkToken) {
    UrlPath p = new UrlPath(routerInfo, path);
    Route route = new RouteImpl(method, p, controllerMethod, routeId, isHttpsOnlyRoutes, checkToken);
    addRoute(route, routeId);
}
Also used : RouteImpl(org.webpieces.router.impl.RouteImpl) UrlPath(org.webpieces.router.impl.UrlPath) Route(org.webpieces.router.impl.Route) MultiRoute(org.webpieces.router.api.routing.MultiRoute)

Example 5 with UrlPath

use of org.webpieces.router.impl.UrlPath in project webpieces by deanhiller.

the class TestCompressionCache method testStartServerTwiceButUrlPathChanges.

@Test
public void testStartServerTwiceButUrlPathChanges() throws IOException {
    File f = new File("src/test/resources/cacheTest1");
    File stagingDir = new File("output/staging");
    FileUtils.copyDirectory(f, stagingDir);
    runBasicServerOnce(stagingDir);
    List<StaticRoute> routes2 = new ArrayList<>();
    routes2.add(new StaticRoute(new UrlPath("", "/public1.4/"), stagingDir.getAbsolutePath() + "/", false, cacheDir));
    //if server is just restarted(no file changes), we should skip reading files...
    cache.setupCache(routes2);
    Assert.assertEquals(2, proxy.getReadFiles().size());
    Assert.assertEquals(2, proxy.getCompressedFiles().size());
}
Also used : StaticRoute(org.webpieces.router.impl.StaticRoute) UrlPath(org.webpieces.router.impl.UrlPath) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Aggregations

UrlPath (org.webpieces.router.impl.UrlPath)5 StaticRoute (org.webpieces.router.impl.StaticRoute)3 ArrayList (java.util.ArrayList)2 MultiRoute (org.webpieces.router.api.routing.MultiRoute)2 Route (org.webpieces.router.impl.Route)2 RouteImpl (org.webpieces.router.impl.RouteImpl)2 File (java.io.File)1 Test (org.junit.Test)1 RouteMeta (org.webpieces.router.impl.RouteMeta)1