Created
February 5, 2013 10:35
-
-
Save spinscale/4713618 to your computer and use it in GitHub Desktop.
spark-groovy-jrebel-helloworld-java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static spark.Spark.*; | |
import spark.*; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
before(new Filter() { // matches all routes | |
@Override | |
public void handle(Request request, Response response) { | |
boolean authenticated; | |
// ... check if authenticated | |
if (!authenticated) { | |
halt(401, "You are not welcome here"); | |
} | |
} | |
}); | |
get(new Route("/hello/:name") { | |
@Override | |
public Object handle(Request request, Response response) { | |
return "Hello: " + request.params(":name"); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment