From 3b636a9d22d48be4fb6ff0b2f7d5cd4012a5d1da Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 10 Dec 2022 15:41:19 +0000 Subject: [PATCH] Update routing slightly, apply #35 to new RouteLogin --- src/Matrix.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Matrix.c b/src/Matrix.c index 6469f31..72e1567 100644 --- a/src/Matrix.c +++ b/src/Matrix.c @@ -52,6 +52,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp) char *requestPath; Array *pathParts; char *pathPart; + RouteArgs routeArgs; requestPath = HttpRequestPath(context); @@ -70,7 +71,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp) LogConfigUnindent(lc); HttpResponseStatus(context, HTTP_OK); - HttpResponseHeader(context, "Server", "Telodendria v" TELODENDRIA_VERSION); + HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION); HttpResponseHeader(context, "Content-Type", "application/json"); /* CORS */ @@ -103,15 +104,19 @@ MatrixHttpHandler(HttpServerContext * context, void *argp) ArrayAdd(pathParts, decoded); } + routeArgs.matrixArgs = args; + routeArgs.context = context; + routeArgs.path = pathParts; + pathPart = MATRIX_PATH_POP(pathParts); if (MATRIX_PATH_EQUALS(pathPart, ".well-known")) { - response = RouteWellKnown(args, context, pathParts); + response = RouteWellKnown(&routeArgs); } else if (MATRIX_PATH_EQUALS(pathPart, "_matrix")) { - response = RouteMatrix(args, context, pathParts); + response = RouteMatrix(&routeArgs); } else { @@ -122,7 +127,6 @@ MatrixHttpHandler(HttpServerContext * context, void *argp) Free(pathPart); HttpSendHeaders(context); - stream = HttpStream(context); if (!response) { @@ -131,6 +135,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp) response = MatrixErrorCreate(M_UNKNOWN); } + stream = HttpStream(context); JsonEncode(response, stream); fprintf(stream, "\n");