Created
February 5, 2013 10:38
-
-
Save spinscale/4713635 to your computer and use it in GitHub Desktop.
spark-groovy-jrebel-simpler
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 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