digitalmars.D.learn - Vibe.d help
- Gestalt Theory (42/42) Sep 21 2016 1. I get this error when trying to run a project in VS. dub
- Martin Tschierschke (17/51) Sep 22 2016 [...]
- Gestalt Theory (21/35) Sep 22 2016 I ignorantly forgot to put the proper image in the image dir ;/
- Gestalt Theory (5/11) Sep 23 2016 sendFile(req, res, Path(req.path));
- Martin Tschierschke (13/24) Sep 26 2016 Sorry, I have problems to find the right link:
1. I get this error when trying to run a project in VS. dub doesn't give the error. First-chance exception: core.exception.AssertError free() called with null array. at vibe-d-0.7.26\source\vibe\utils\memory.d(110) It constantly pops up then I get an access violation and crash. 2. Many vibe.d HTTP Server options seem not to be implemented. Is this still the case? e.g., http://vibed.org/api/vibe.http.server/HTTPServerSettings.maxRequestTime 3. How to serve static files properly? void images(HTTPServerRequest req, HTTPServerResponse res) { writeln("images Request"); write("Path = "); writeln(req.fullURL); // Somehow reship request out } ... router.get("/images/*", &images); I would like to be able to serve them but also log or redirect if possible. The messages are written. I tried to also serve directly and it didn't work, which is why I used a handler in the first place. router.get("/images/*", serveStaticFiles("images/")); I imagine the path is not correct. I am on windows and created an images sub dir in the projects(same depth as views, etc) but the images were not served. I didn't want to hard code this path, maybe it should be? 4. How to setup load balancing and virtual hosts? I know one can use a front end to do this but I saw a vibedist project that seems to be dead. Obviously one can make multiple HTTPServers, but this might get a bit messy. What I want to eventually do is server multiple secure virtual domains with http's being redirected to https. I'd like to probably use one vibe.d instance unless there is good reason not to. The sites, at this point, won't have many req/sec. Maybe eventually I'll need to separate in to multiple processes. 5. Many other frameworks seem to support "hot swapping" of files while the sever is running rather than having to recompile. Recompiling the diet templates/project is slow and requires restarting the server and all that. Is there any way to get vibe.d to automatically monitor the projects folder or templates for changes and then somehow recompile and update/etc? Thanks.
Sep 21 2016
On Thursday, 22 September 2016 at 01:38:12 UTC, Gestalt Theory wrote:1. I get this error when trying to run a project in VS. dub doesn't give the error. First-chance exception: core.exception.AssertError free() called with null array. at vibe-d-0.7.26\source\vibe\utils\memory.d(110) It constantly pops up then I get an access violation and crash. 2. Many vibe.d HTTP Server options seem not to be implemented. Is this still the case? e.g., http://vibed.org/api/vibe.http.server/HTTPServerSettings.maxRequestTime 3. How to serve static files properly? void images(HTTPServerRequest req, HTTPServerResponse res) { writeln("images Request"); write("Path = "); writeln(req.fullURL); // Somehow reship request out } ... router.get("/images/*", &images); I would like to be able to serve them but also log or redirect if possible. The messages are written. I tried to also serve directly and it didn't work, which is why I used a handler in the first place. router.get("/images/*", serveStaticFiles("images/")); I imagine the path is not correct. I am on windows and created an images sub dir in the projects(same depth as views, etc) but the images were not served. I didn't want to hard code this path, maybe it should be?[...]5. Many other frameworks seem to support "hot swapping" of files while the sever is running rather than having to recompile. Recompiling the diet templates/project is slow and requires restarting the server and all that. Is there any way to get vibe.d to automatically monitor the projects folder or templates for changes and then somehow recompile and update/etc? Thanks.Just to point 3. I hope I can give a hint, the problem is, that the match is not the * but /images/*, so router.get("/images/*", serveStaticFiles("images/")) will look in PROJECTHOME/images/images/ for the file. For my .css files located in PROJECTHOME/public/styles/ I used: router.get("/styles/*", serveStaticFiles("public/")) if you put your images in PROJECTHOME/public/images router.get("/images/*", serveStaticFiles("public/")); should work. 5. There is a solution, hopefully I can find the link and post it later.
Sep 22 2016
Just to point 3. I hope I can give a hint, the problem is, that the match is not the * but /images/*, so router.get("/images/*", serveStaticFiles("images/")) will look in PROJECTHOME/images/images/ for the file. For my .css files located in PROJECTHOME/public/styles/ I used: router.get("/styles/*", serveStaticFiles("public/")) if you put your images in PROJECTHOME/public/images router.get("/images/*", serveStaticFiles("public/")); should work.I ignorantly forgot to put the proper image in the image dir ;/ But it would return the default page rather than error so I thought the route was wrong. e.g., I browsed to /images/image.jpg and I got the default page. I'd rather it error out(error page). Also, I probably would still like to know how to serve the files statically from a handler. Could I have two routes, one that does it statically and the other with handler, for the same content? Also, my route is router.get("/images/*", serveStaticFiles("/")); Does this not open up the base dir for possible attacks? Seems like router.get("*", serveStaticFiles("/images")); would be better, although this won't work because it will match anything. Seems kinda bizarre how it works. If I serve the files in a handler maybe I could have more control? I guess I could look at the source for serveStaticFiles... seems there is some functions that are used like sendFile that should work.5. There is a solution, hopefully I can find the link and post it later.Cool, that will help speed things up.
Sep 22 2016
On Thursday, 22 September 2016 at 09:14:46 UTC, Martin Tschierschke wrote:On Thursday, 22 September 2016 at 01:38:12 UTC, Gestalt Theory wrote:sendFile(req, res, Path(req.path)); Does the trick inside the handler.3. How to serve static files properly?5. There is a solution, hopefully I can find the link and post it later.Any news on this?
Sep 23 2016
On Friday, 23 September 2016 at 21:32:59 UTC, Gestalt Theory wrote:On Thursday, 22 September 2016 at 09:14:46 UTC, Martin Tschierschke wrote:Sorry, I have problems to find the right link: It is mentioned here: http://vibed.org/features -> Integrated load balancing (bottom of page) And here you find the part for template caching, an option with in the new template engine: ->Experimental HTML template caching https://github.com/rejectedsoftware/diet-ng But the best place to ask would be in the vibe.d forum, where Sönke is able and willing to help! http://vibed.org/ -> http://forum.rejectedsoftware.com/ Regards mt.On Thursday, 22 September 2016 at 01:38:12 UTC, Gestalt Theory wrote:sendFile(req, res, Path(req.path)); Does the trick inside the handler.3. How to serve static files properly?5. There is a solution, hopefully I can find the link and post it later.Any news on this?
Sep 26 2016