All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spark.LambdaTest Maven / Gradle / Ivy

Go to download

A micro framework for creating web applications in Kotlin and Java 8 with minimal effort

There is a newer version: 2.9.4
Show newest version
package spark;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static spark.Spark.before;
import static spark.Spark.get;
import static spark.Spark.halt;

/**
 * Created by Per Wendel on 2014-05-10.
 */
public class LambdaTest {

    private static final Logger LOGGER = LoggerFactory.getLogger(LambdaTest.class);
    public static void main(String[] args) {
        get("/hello", (request, response) -> {
            LOGGER.info("request = " + request.pathInfo());
            return "Hello World";
        });

        before("/protected/*", "application/xml", (request, response) -> {
            halt(401, "fuck off");
        });

        before("/protected/*", "application/json", (request, response) -> {
            halt(401, "{\"message\": \"Go Away!\"}");
        });

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy