1 module websettings; 2 3 import diamond.core.websettings; 4 5 private class WebdWebSettings : WebSettings 6 { 7 import vibe.d : HTTPServerRequest, HTTPServerResponse, HTTPServerErrorInfo; 8 import diamond.http; 9 import diamond.authentication; 10 11 private: 12 this() 13 { 14 super(); 15 } 16 17 public: 18 override void onApplicationStart() 19 { 20 import webd.core.config; 21 loadWebdConfig(); 22 } 23 24 override bool onBeforeRequest(HttpClient client) 25 { 26 return true; 27 } 28 29 override void onAfterRequest(HttpClient client) 30 { 31 } 32 33 override void onHttpError(Throwable thrownError, HTTPServerRequest request, 34 HTTPServerResponse response, HTTPServerErrorInfo error) 35 { 36 response.bodyWriter.write(thrownError.toString()); 37 } 38 39 override void onNotFound(HTTPServerRequest request, HTTPServerResponse response) 40 { 41 import std..string : format; 42 43 response.bodyWriter.write(format("The path '%s' wasn't found.'", request.path)); 44 } 45 46 override void onStaticFile(HttpClient client) 47 { 48 49 } 50 } 51 52 void initializeWebSettings() 53 { 54 webSettings = new WebdWebSettings; 55 }