diff --git a/litelist-api/dub.json b/litelist-api/dub.json index 891ef25..2ded7bf 100644 --- a/litelist-api/dub.json +++ b/litelist-api/dub.json @@ -7,10 +7,10 @@ "botan": "~>1.13.5", "d-properties": "~>1.0.5", "d2sqlite3": "~>1.0.0", - "handy-httpd": "~>8.1.0", + "handy-httpd": "~>8.2.0", "jwt": "~>0.4.0", "resusage": "~>0.3.2", - "slf4d": "~>2.4.3" + "slf4d": "~>3.0.0" }, "description": "API for the litelist application.", "license": "MIT", diff --git a/litelist-api/dub.selections.json b/litelist-api/dub.selections.json index 46d26a1..897c4f9 100644 --- a/litelist-api/dub.selections.json +++ b/litelist-api/dub.selections.json @@ -5,13 +5,13 @@ "botan-math": "1.0.4", "d-properties": "1.0.5", "d2sqlite3": "1.0.0", - "handy-httpd": "8.1.0", + "handy-httpd": "8.2.0", "httparsed": "1.2.1", "jwt": "0.4.0", "memutils": "1.0.10", "path-matcher": "1.1.3", "resusage": "0.3.2", - "slf4d": "2.4.3", + "slf4d": "3.0.0", "streams": "3.5.0" } } diff --git a/litelist-api/source/app.d b/litelist-api/source/app.d index 73fb864..312a6f1 100644 --- a/litelist-api/source/app.d +++ b/litelist-api/source/app.d @@ -3,7 +3,7 @@ import slf4d; import slf4d.default_provider; void main() { - auto provider = new shared DefaultProvider(true, Levels.INFO); + auto provider = new DefaultProvider(true, Levels.INFO); // provider.getLoggerFactory().setModuleLevelPrefix("handy_httpd", Levels.DEBUG); configureLoggingProvider(provider); @@ -27,10 +27,11 @@ private HttpServer initServer() { import auth : TokenFilter, AdminFilter, loadTokenSecret; - ServerConfig config = ServerConfig.defaultValues(); + ServerConfig config; config.enableWebSockets = false; config.workerPoolSize = 3; config.connectionQueueSize = 10; + config.receiveBufferSize = 4096; bool useCorsHeaders = true; if (exists("application.properties")) { Properties props = Properties("application.properties"); @@ -63,10 +64,6 @@ private HttpServer initServer() { mainHandler.addMapping(Method.GET, API_PATH ~ "/status", &handleStatus); mainHandler.addMapping(Method.POST, API_PATH ~ "/register", &createNewUser); mainHandler.addMapping(Method.POST, API_PATH ~ "/login", &handleLogin); - // mainHandler.addMapping(Method.GET, API_PATH ~ "/shutdown", (ref HttpRequestContext ctx) { - // ctx.response.writeBodyString("Shutting down!"); - // ctx.server.stop(); - // }); HttpRequestHandler optionsHandler = toHandler((ref HttpRequestContext ctx) { ctx.response.setStatus(HttpStatus.OK); @@ -87,15 +84,14 @@ private HttpServer initServer() { authHandler.addMapping(Method.DELETE, API_PATH ~ "/lists/:listId:ulong/notes/:noteId:ulong", &deleteNote); authHandler.addMapping(Method.DELETE, API_PATH ~ "/lists/:listId:ulong/notes", &deleteAllNotes); HttpRequestFilter tokenFilter = new TokenFilter(loadTokenSecret()); - HttpRequestFilter adminFilter = new AdminFilter(); + mainHandler.addMapping(API_PATH ~ "/**", new FilteredRequestHandler(authHandler, [tokenFilter])); // Separate handler for admin paths, protected by an AdminFilter. PathHandler adminHandler = new PathHandler(); adminHandler.addMapping(Method.GET, API_PATH ~ "/admin/users", &getAllUsers); + HttpRequestFilter adminFilter = new AdminFilter(); mainHandler.addMapping(API_PATH ~ "/admin/**", new FilteredRequestHandler(adminHandler, [tokenFilter, adminFilter])); - mainHandler.addMapping(API_PATH ~ "/**", new FilteredRequestHandler(authHandler, [tokenFilter])); - return new HttpServer(mainHandler, config); }