Package com.vtence.molecule.middlewares

Examples of com.vtence.molecule.middlewares.StaticAssets


    public void run(WebServer server) throws IOException {
        // Serve files in this directory, based on the path of the request.
        FileServer files = new FileServer(locateOnClasspath("examples/fox"));
        // Serve static assets (e.g. js files, images, css files, etc) for any request whose path starts
        // with one of the url prefixes specified (in this example, we're serving all requests).
        StaticAssets assets = new StaticAssets(files).serve("/");
        // If request targets a directory (i.e. request path ends with "/"),
        // serve the index.html file located in that directory (the default behavior).
        assets.index("index.html");

        // Log all accesses to the server in apache common log format
        server.add(new ApacheCommonLogger(logger))
              .start(assets);
    }
View Full Code Here


    public void run(WebServer server) throws IOException {
        File content = ResourceLocator.locateOnClasspath("examples/fox");
        // Add cache directives to the response when serving files
        FileServer files = new FileServer(content).header(CACHE_CONTROL, "public; max-age=60");
        // Serve static assets for css, js and image files from the content dir.
        StaticAssets assets = new StaticAssets(files).serve("/css", "/js", "/images");
        // We use Mustache templates with an .html extension
        Templates templates = new Templates(new JMustacheRenderer().fromDir(content).extension("html"));
        final Template index = templates.named("index");

              // Add content length header when size of content is known
View Full Code Here

TOP

Related Classes of com.vtence.molecule.middlewares.StaticAssets

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.