In node.js one can just adjust the url of a request by doing something like this:
app.use(function(req, res, next) {
if (req.url.slice(-1) === '/') {
req.url = req.url.slice(0, -1);
}
next();
});
The following fails in dart, as all the request properties, the Uri and its path only have getters. Any suggestions how this can be achieved? Maybe by creating a new HttpRequest and piping its response to the original request?
void main() {
var virDir = new VirtualDirectory("../somewhere_else");
HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080).then((server) {
print("Serving at ${server.address}:${server.port}");
server.listen((HttpRequest request) {
request.uri.path = "/newPath";
virDir.serverRequest(request);
});
});
}