Skip to content

Instantly share code, notes, and snippets.

@spinscale
Created February 5, 2013 10:38
Show Gist options
  • Save spinscale/4713635 to your computer and use it in GitHub Desktop.
Save spinscale/4713635 to your computer and use it in GitHub Desktop.
spark-groovy-jrebel-simpler
import spark.*
class WebServer extends SparkGroovy {
static void main(String[] args) {
new WebServer().init();
}
void init() {
before { Request req, Response res ->
boolean authenticated;
// ... check if authenticated
if (!authenticated) {
halt(401, "You are not welcome here");
}
}
get "/hello/:name", { Request request, Response response ->
return "Hello " + request.params('name') + "\n"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment