How to Get Current URL Full Address
How to get current url Full Address in GET Request?
router.route("/").linkFunction((request) async { // final page = request.path.variables["page"]; @Bind.query("page") String page;
print(request.path.toString());
print(request.connectionInfo.remoteAddress.address);
print(request.connectionInfo.remoteAddress.host);
print(request.connectionInfo.remoteAddress.rawAddress);
print(router.basePath);
print("PAGE: $page");
return json(page);
});
i Want to get http://localhost:8888/ Thanks
Each Request instance has a raw property that provides access to the underlying HttpRequest. Access to the full path is done using the requestedUri property of the underlying HttpRequest.
router
.route("/example")
.linkFunction((request) async {
return Response.ok({"requestedUri": "${request.raw.requestedUri}"});
});
This produces the following output: {"requestedUri":"http://localhost:8888/example"}
Each
Requestinstance has a raw property that provides access to the underlying HttpRequest. Access to the full path is done using the requestedUri property of the underlyingHttpRequest.router .route("/example") .linkFunction((request) async { return Response.ok({"requestedUri": "${request.raw.requestedUri}"}); });This produces the following output:
{"requestedUri":"http://localhost:8888/example"}
thanks. solved!