January 2019
Intermediate to advanced
378 pages
11h 35m
English
Typically, we would write the following few lines to bring up a hello world API with Spark:
1 import static spark.Spark.*;23 public class MyHelloWorld {4 public static void main(String[] args) {5 get("/sayhello", (request, response) -> "Hello Reader");6 }7 }
That's it! Line one, spark.Spark.*, as indicated in the preceding code snippet, does the magic. By using CURL (curl http://localhost:4567/sayhello), we would visualize the following request and response as output for the previous code:
Request: GET http://localhost:4567/sayhello Response: Hello Reader
As we can see in the preceding snippet, curl hits the application, so the lambda function of Spark.* fires and the client (curl in this case) gets the output ...
Read now
Unlock full access