Skip to content

Instantly share code, notes, and snippets.

@settermjd
Created February 26, 2015 12:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save settermjd/b9f4c875c252c587e737 to your computer and use it in GitHub Desktop.
Attempting to know if the following examples are effectively the same thing
/**
* Are these two examples the same, with the second just being more verbose?
*/
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
// ---------------------------------------------------------------------------
package com.simonrice.sparkservletexample;
import spark.Request;
import spark.Response;
import spark.Route;
import spark.Spark;
import spark.servlet.SparkApplication;
public class HelloWorld implements SparkApplication {
@Override
public void init() {
Spark.get(new Route("/hello") {
@Override
public Object handle(Request request, Response response) {
return "Hello World!";
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment