import handy_httpd; import handy_httpd.handlers.path_handler; import std.stdio; import d2sqlite3; import db; import api_modules.auth; void main() { ServerConfig config; config.enableWebSockets = false; config.port = 8080; config.workerPoolSize = 3; config.defaultHeaders["Access-Control-Allow-Origin"] = "*"; config.defaultHeaders["Access-Control-Allow-Methods"] = "*"; config.defaultHeaders["Access-Control-Request-Method"] = "*"; config.defaultHeaders["Access-Control-Allow-Headers"] = "Authorization, Content-Length, Content-Type"; PathHandler handler = new PathHandler(); handler.addMapping(Method.OPTIONS, "/api/**", &optionsEndpoint); handler.addMapping(Method.POST, "/api/auth/login", &loginEndpoint); HttpServer server = new HttpServer(handler, config); server.start(); } void optionsEndpoint(ref HttpRequestContext ctx) { ctx.response.status = HttpStatus.OK; }