summaryrefslogtreecommitdiffstats
path: root/server/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-22 15:35:29 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-22 15:35:29 +0100
commit7863a228b54722d7b1b42f9e39e2ee115a97aee5 (patch)
tree01576c5e63d15786001d56fcfb3ee76e8082694d /server/src/ch/asynk
parent3134a588789cde591daa6065cf5e5db4b3c82523 (diff)
downloadRustAndDust-server.zip
RustAndDust-server.tar.gz
Diffstat (limited to 'server/src/ch/asynk')
-rw-r--r--server/src/ch/asynk/rustanddust/server/Server.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/server/src/ch/asynk/rustanddust/server/Server.java b/server/src/ch/asynk/rustanddust/server/Server.java
new file mode 100644
index 0000000..4a2000c
--- /dev/null
+++ b/server/src/ch/asynk/rustanddust/server/Server.java
@@ -0,0 +1,37 @@
+package ch.asynk.rustanddust.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+public class Server
+{
+
+ public static void main(String[] args) throws Exception
+ {
+ HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
+ server.createContext("/test", new MyHandler());
+ server.setExecutor(null);
+ server.start();
+ // System.exit(0);
+ }
+
+ static class MyHandler implements HttpHandler
+ {
+ @Override
+ public void handle(HttpExchange t) throws IOException
+ {
+ System.err.print("answering ...");
+ String response = "This is the response";
+ t.sendResponseHeaders(200, response.length());
+ OutputStream os = t.getResponseBody();
+ os.write(response.getBytes());
+ os.close();
+ System.err.print("done.");
+ }
+ }
+}