Updated to handy-httpd v8.2.0 and slf4d v3.0.0
This commit is contained in:
parent
df3a4858cf
commit
978c3f1bd7
|
@ -7,10 +7,10 @@
|
||||||
"botan": "~>1.13.5",
|
"botan": "~>1.13.5",
|
||||||
"d-properties": "~>1.0.5",
|
"d-properties": "~>1.0.5",
|
||||||
"d2sqlite3": "~>1.0.0",
|
"d2sqlite3": "~>1.0.0",
|
||||||
"handy-httpd": "~>8.1.0",
|
"handy-httpd": "~>8.2.0",
|
||||||
"jwt": "~>0.4.0",
|
"jwt": "~>0.4.0",
|
||||||
"resusage": "~>0.3.2",
|
"resusage": "~>0.3.2",
|
||||||
"slf4d": "~>2.4.3"
|
"slf4d": "~>3.0.0"
|
||||||
},
|
},
|
||||||
"description": "API for the litelist application.",
|
"description": "API for the litelist application.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
"botan-math": "1.0.4",
|
"botan-math": "1.0.4",
|
||||||
"d-properties": "1.0.5",
|
"d-properties": "1.0.5",
|
||||||
"d2sqlite3": "1.0.0",
|
"d2sqlite3": "1.0.0",
|
||||||
"handy-httpd": "8.1.0",
|
"handy-httpd": "8.2.0",
|
||||||
"httparsed": "1.2.1",
|
"httparsed": "1.2.1",
|
||||||
"jwt": "0.4.0",
|
"jwt": "0.4.0",
|
||||||
"memutils": "1.0.10",
|
"memutils": "1.0.10",
|
||||||
"path-matcher": "1.1.3",
|
"path-matcher": "1.1.3",
|
||||||
"resusage": "0.3.2",
|
"resusage": "0.3.2",
|
||||||
"slf4d": "2.4.3",
|
"slf4d": "3.0.0",
|
||||||
"streams": "3.5.0"
|
"streams": "3.5.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import slf4d;
|
||||||
import slf4d.default_provider;
|
import slf4d.default_provider;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
auto provider = new shared DefaultProvider(true, Levels.INFO);
|
auto provider = new DefaultProvider(true, Levels.INFO);
|
||||||
// provider.getLoggerFactory().setModuleLevelPrefix("handy_httpd", Levels.DEBUG);
|
// provider.getLoggerFactory().setModuleLevelPrefix("handy_httpd", Levels.DEBUG);
|
||||||
configureLoggingProvider(provider);
|
configureLoggingProvider(provider);
|
||||||
|
|
||||||
|
@ -27,10 +27,11 @@ private HttpServer initServer() {
|
||||||
|
|
||||||
import auth : TokenFilter, AdminFilter, loadTokenSecret;
|
import auth : TokenFilter, AdminFilter, loadTokenSecret;
|
||||||
|
|
||||||
ServerConfig config = ServerConfig.defaultValues();
|
ServerConfig config;
|
||||||
config.enableWebSockets = false;
|
config.enableWebSockets = false;
|
||||||
config.workerPoolSize = 3;
|
config.workerPoolSize = 3;
|
||||||
config.connectionQueueSize = 10;
|
config.connectionQueueSize = 10;
|
||||||
|
config.receiveBufferSize = 4096;
|
||||||
bool useCorsHeaders = true;
|
bool useCorsHeaders = true;
|
||||||
if (exists("application.properties")) {
|
if (exists("application.properties")) {
|
||||||
Properties props = Properties("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.GET, API_PATH ~ "/status", &handleStatus);
|
||||||
mainHandler.addMapping(Method.POST, API_PATH ~ "/register", &createNewUser);
|
mainHandler.addMapping(Method.POST, API_PATH ~ "/register", &createNewUser);
|
||||||
mainHandler.addMapping(Method.POST, API_PATH ~ "/login", &handleLogin);
|
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) {
|
HttpRequestHandler optionsHandler = toHandler((ref HttpRequestContext ctx) {
|
||||||
ctx.response.setStatus(HttpStatus.OK);
|
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/:noteId:ulong", &deleteNote);
|
||||||
authHandler.addMapping(Method.DELETE, API_PATH ~ "/lists/:listId:ulong/notes", &deleteAllNotes);
|
authHandler.addMapping(Method.DELETE, API_PATH ~ "/lists/:listId:ulong/notes", &deleteAllNotes);
|
||||||
HttpRequestFilter tokenFilter = new TokenFilter(loadTokenSecret());
|
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.
|
// Separate handler for admin paths, protected by an AdminFilter.
|
||||||
PathHandler adminHandler = new PathHandler();
|
PathHandler adminHandler = new PathHandler();
|
||||||
adminHandler.addMapping(Method.GET, API_PATH ~ "/admin/users", &getAllUsers);
|
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 ~ "/admin/**", new FilteredRequestHandler(adminHandler, [tokenFilter, adminFilter]));
|
||||||
|
|
||||||
mainHandler.addMapping(API_PATH ~ "/**", new FilteredRequestHandler(authHandler, [tokenFilter]));
|
|
||||||
|
|
||||||
return new HttpServer(mainHandler, config);
|
return new HttpServer(mainHandler, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue