diff options
Diffstat (limited to 'central/src/main/java/moe/yuuta/dn42peering/portal/RenderingUtils.java')
-rw-r--r-- | central/src/main/java/moe/yuuta/dn42peering/portal/RenderingUtils.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/central/src/main/java/moe/yuuta/dn42peering/portal/RenderingUtils.java b/central/src/main/java/moe/yuuta/dn42peering/portal/RenderingUtils.java new file mode 100644 index 0000000..a8514f3 --- /dev/null +++ b/central/src/main/java/moe/yuuta/dn42peering/portal/RenderingUtils.java @@ -0,0 +1,26 @@ +package moe.yuuta.dn42peering.portal; + +import io.vertx.core.AsyncResult; +import io.vertx.core.Future; +import io.vertx.core.Handler; +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpHeaders; +import io.vertx.ext.web.api.service.ServiceResponse; + +import javax.annotation.Nonnull; + +public class RenderingUtils { + public static Handler<AsyncResult<Buffer>> getGeneralRenderingHandler(@Nonnull Handler<AsyncResult<ServiceResponse>> handler) { + return res -> { + if (res.succeeded()) { + handler.handle(Future.succeededFuture(new ServiceResponse(200, + null, + res.result(), + MultiMap.caseInsensitiveMultiMap().add(HttpHeaders.CONTENT_TYPE, "text/html")))); + } else { + handler.handle(Future.failedFuture(res.cause())); + } + }; + } +} |