aqueduct icon indicating copy to clipboard operation
aqueduct copied to clipboard

How to Get Current URL Full Address

Open 5lineofcode opened this issue 6 years ago • 2 comments

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

5lineofcode avatar Jun 23 '20 02:06 5lineofcode

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"}

brianmpalma-sk avatar Jul 07 '20 16:07 brianmpalma-sk

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"}

thanks. solved!

5lineofcode avatar Jul 09 '20 10:07 5lineofcode