Remove debug code from main class, use vertx's timeout handler instead of our debugging version
This commit is contained in:
parent
f0d8256f07
commit
53aa9ce368
@ -30,6 +30,7 @@ import io.vertx.ext.web.RoutingContext;
|
|||||||
import io.vertx.ext.web.handler.BodyHandler;
|
import io.vertx.ext.web.handler.BodyHandler;
|
||||||
import io.vertx.ext.web.handler.LoggerFormat;
|
import io.vertx.ext.web.handler.LoggerFormat;
|
||||||
import io.vertx.ext.web.handler.LoggerHandler;
|
import io.vertx.ext.web.handler.LoggerHandler;
|
||||||
|
import io.vertx.ext.web.handler.TimeoutHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.frozenorb.apiv3.handler.ActorAttributeHandler;
|
import net.frozenorb.apiv3.handler.ActorAttributeHandler;
|
||||||
@ -102,6 +103,7 @@ import java.time.Instant;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class APIv3 extends AbstractVerticle {
|
public final class APIv3 extends AbstractVerticle {
|
||||||
@ -242,22 +244,10 @@ public final class APIv3 extends AbstractVerticle {
|
|||||||
Router http = Router.router(vertx);
|
Router http = Router.router(vertx);
|
||||||
|
|
||||||
http.route().handler(LoggerHandler.create(LoggerFormat.TINY));
|
http.route().handler(LoggerHandler.create(LoggerFormat.TINY));
|
||||||
//http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(5)));
|
http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(5)));
|
||||||
http.route().handler((ctx) -> {
|
|
||||||
long tid = ctx.vertx().setTimer(5000, (t) -> {
|
|
||||||
log.error(ctx.getBodyAsString());
|
|
||||||
ctx.fail(503);
|
|
||||||
});
|
|
||||||
|
|
||||||
ctx.addBodyEndHandler((v) -> {
|
|
||||||
ctx.vertx().cancelTimer(tid);
|
|
||||||
});
|
|
||||||
|
|
||||||
ctx.next();
|
|
||||||
});
|
|
||||||
http.route().method(HttpMethod.PUT).method(HttpMethod.POST).method(HttpMethod.DELETE).handler(BodyHandler.create());
|
|
||||||
http.route().handler(new ActorAttributeHandler());
|
http.route().handler(new ActorAttributeHandler());
|
||||||
http.route().handler(new AuthorizationHandler());
|
http.route().handler(new AuthorizationHandler());
|
||||||
|
http.route().method(HttpMethod.PUT).method(HttpMethod.POST).method(HttpMethod.DELETE).handler(BodyHandler.create());
|
||||||
http.exceptionHandler(Throwable::printStackTrace);
|
http.exceptionHandler(Throwable::printStackTrace);
|
||||||
|
|
||||||
// TODO: The commented out routes
|
// TODO: The commented out routes
|
||||||
@ -365,11 +355,6 @@ public final class APIv3 extends AbstractVerticle {
|
|||||||
public static void respondJson(RoutingContext ctx, int code, Object response) {
|
public static void respondJson(RoutingContext ctx, int code, Object response) {
|
||||||
ctx.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());
|
ctx.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());
|
||||||
ctx.response().setStatusCode(code);
|
ctx.response().setStatusCode(code);
|
||||||
|
|
||||||
if (!ctx.request().path().contains("dumps")) {
|
|
||||||
//log.info(gson.toJson(response));
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.response().end(gson.toJson(response));
|
ctx.response().end(gson.toJson(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user