Gymboard/gymboard-uploads/source/app.d

32 lines
956 B
D
Raw Normal View History

2023-03-29 15:29:19 +00:00
import std.stdio;
import handy_httpd;
import handy_httpd.handlers.path_delegating_handler;
2023-04-02 10:33:05 +00:00
import slf4d;
import slf4d.default_provider;
2023-03-29 15:29:19 +00:00
import handlers;
void main() {
2023-04-02 10:33:05 +00:00
// Configure logging
auto provider = new shared DefaultProvider(true, Levels.TRACE);
configureLoggingProvider(provider);
2023-03-29 15:29:19 +00:00
PathDelegatingHandler pathHandler = new PathDelegatingHandler();
pathHandler.addMapping("GET", "/status", (ref HttpRequestContext ctx) {
ctx.response.writeBodyString("online");
});
pathHandler.addMapping("POST", "/uploads", new VideoUploadHandler());
pathHandler.addMapping("POST", "/uploads/{uploadId}/process", new VideoProcessingHandler());
2023-03-29 15:29:19 +00:00
HttpServer server = new HttpServer(pathHandler, getServerConfig());
server.start();
}
private ServerConfig getServerConfig() {
ServerConfig serverConfig = ServerConfig.defaultValues();
serverConfig.port = 8085;
serverConfig.workerPoolSize = 10;
serverConfig.reuseAddress = true;
return serverConfig;
}