Created
February 26, 2015 12:15
-
-
Save settermjd/b9f4c875c252c587e737 to your computer and use it in GitHub Desktop.
Attempting to know if the following examples are effectively the same thing
This file contains 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
/** | |
* 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