Created
December 21, 2016 15:25
-
-
Save kleinron/2855c08538613d0e73cabdbad2a75fb0 to your computer and use it in GitHub Desktop.
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
package com.leadspace.tools; | |
import spark.Request; | |
import spark.Response; | |
import spark.Route; | |
import spark.Spark; | |
import java.util.Arrays; | |
public class HelloWeb { | |
public static void main(String[] args) { | |
Spark.port(8484); | |
Spark.get("/ping", new Pong()); | |
Spark.get("/ping/", new Pong()); | |
// Spark.get("/ping", new Route() { | |
// public Object handle(Request request, Response response) throws Exception { | |
// String myHeader = request.headers("x-ron"); | |
// if (myHeader != null) { | |
// System.out.println(myHeader); | |
// } | |
// | |
// System.out.println(request.headers()); | |
// | |
// String a = request.queryParams("a"); | |
// System.out.println("a = " + a); | |
// System.out.println("a = " + Arrays.toString(request.queryParamsValues("a"))); | |
// return "pong\n"; | |
// } | |
// }); | |
} | |
private static class Pong implements Route{ | |
public Object handle(Request request, Response response) throws Exception { | |
String myHeader = request.headers("x-ron"); | |
if (myHeader != null) { | |
System.out.println(myHeader); | |
} | |
System.out.println(request.headers()); | |
String a = request.queryParams("a"); | |
System.out.println("a = " + a); | |
System.out.println("a = " + Arrays.toString(request.queryParamsValues("a"))); | |
return "pong\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment