From 12e25c9c136a32ed4881435acec79f31ed53d7ba Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:54:52 +0100 Subject: [PATCH] Attempt to add proper support for channel handles. --- src/main/java/me/kavin/piped/server/ServerLauncher.java | 9 +++++++++ testing/api-test.sh | 1 + 2 files changed, 10 insertions(+) diff --git a/src/main/java/me/kavin/piped/server/ServerLauncher.java b/src/main/java/me/kavin/piped/server/ServerLauncher.java index 34b06aa..1c6b3f3 100644 --- a/src/main/java/me/kavin/piped/server/ServerLauncher.java +++ b/src/main/java/me/kavin/piped/server/ServerLauncher.java @@ -170,6 +170,14 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher { } catch (Exception e) { return getErrorResponse(e, request.getPath()); } + })).map(GET, "/@/:handle", AsyncServlet.ofBlocking(executor, request -> { + try { + return getJsonResponse( + ChannelHandlers.channelResponse("@" + request.getPathParameter("handle")), + "public, max-age=600", true); + } catch (Exception e) { + return getErrorResponse(e, request.getPath()); + } })).map(GET, "/nextpage/channel/:channelId", AsyncServlet.ofBlocking(executor, request -> { try { return getJsonResponse(ChannelHandlers.channelPageResponse(request.getPathParameter("channelId"), @@ -526,6 +534,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher { return Config.create() .with("http.listenAddresses", Config.ofValue(ofInetSocketAddress(), new InetSocketAddress(Constants.PORT))) + .with("bytebuf.useWatchdog", String.valueOf(true)) .with("workers", Constants.HTTP_WORKERS); } }; diff --git a/testing/api-test.sh b/testing/api-test.sh index 8e2b578..b0aee74 100755 --- a/testing/api-test.sh +++ b/testing/api-test.sh @@ -16,6 +16,7 @@ curl "${CURLOPTS[@]}" $HOST/trending?region=US || exit 1 curl "${CURLOPTS[@]}" $HOST/channel/UCsXVk37bltHxD1rDPwtNM8Q || exit 1 curl "${CURLOPTS[@]}" $HOST/c/inanutshell || exit 1 curl "${CURLOPTS[@]}" $HOST/user/Kurzgesagt || exit 1 +curl "${CURLOPTS[@]}" $HOST/@/kurzgesagt || exit 1 # Channel Nextpage CHANNEL_NEXTPAGE=$(curl -s -o - -f $HOST/channel/UCsXVk37bltHxD1rDPwtNM8Q | jq -r .nextpage)