req
如果太短,我正在尝试显示错误消息。这是代码:
import std.stdio;
import vibe.d;
Database mydatabase;
void main()
{
// ...
router.get("*", &myStuff); // all other request
listenHTTP(settings, router);
runApplication();
}
@errorDisplay!showPageNotFound
void myStuff(HTTPServerRequest req, HTTPServerResponse res) // I need this to handle any accessed URLs
{
if(req.path.length > 10)
{
// ...
}
else
{
throw new Exception("Nothing do not found");
}
}
void showPageNotFound(string _error = null)
{
render!("error.dt", _error);
}
错误是:
source\app.d(80,2): Error: template instance app.showPageNotFound.render!("error.dt", _error).render!("app", "app.showPageNotFound") error instantiating
如果我在做:
void showPageNotFound(string _error = null)
{
res.render!("error.dt", _error);
}
我收到错误:
Error: undefined identifier 'res'