public static void main(String[] args) {
        get("/hi", (request, response) -> {
            request.attribute("foo", "bar");
            return null;
        });

        after("/hi", (request, response) -> {
            for (String attr : request.attributes()) {
                LOGGER.info("attr: " + attr);
            }
        });

        after("/hi", (request, response) -> {
            String foo = request.attribute("foo");
            response.body(asXml("foo", foo));
        });
    }
Example showing the use of attributes

@author Per Wendel
src/test/java/spark/examples/filter/FilterExampleAttributes.java