clean up debug RedditAPI

master
adb 4 years ago
parent 766d53713e
commit 760b73261a

@ -17,7 +17,6 @@ sourceSets {
repositories {
mavenCentral()
}
apply plugin: "java"
dependencies {
//jreddit 1.0.4 dependencies

@ -0,0 +1,21 @@
package sh.adb.RandomRedditMemesAPI;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
class CommunityHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
InputStream is = t.getRequestBody();
//is.read();
String response = "This is the response";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}

@ -0,0 +1,21 @@
package sh.adb.RandomRedditMemesAPI;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
class FallbackHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
InputStream is = t.getRequestBody();
//is.read();
String response = "404";
t.sendResponseHeaders(404, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}
Loading…
Cancel
Save