Package com.vtence.molecule.middlewares

Examples of com.vtence.molecule.middlewares.FileServer


        this.logger = logger;
    }

    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).
View Full Code Here


    private static final Object NO_CONTEXT = null;

    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");
View Full Code Here

TOP

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

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.