Skip to content

Instantly share code, notes, and snippets.

@spinscale
Created February 5, 2013 10:35
Show Gist options
  • Save spinscale/4713618 to your computer and use it in GitHub Desktop.
Save spinscale/4713618 to your computer and use it in GitHub Desktop.
spark-groovy-jrebel-helloworld-java
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