How to get client remote ip address in resource controller












0















How can I access request.connectioninfo.remoteaddress in a function of a resourcecontroller? I need to store and log the client remote IP.










share|improve this question



























    0















    How can I access request.connectioninfo.remoteaddress in a function of a resourcecontroller? I need to store and log the client remote IP.










    share|improve this question

























      0












      0








      0








      How can I access request.connectioninfo.remoteaddress in a function of a resourcecontroller? I need to store and log the client remote IP.










      share|improve this question














      How can I access request.connectioninfo.remoteaddress in a function of a resourcecontroller? I need to store and log the client remote IP.







      dart aqueduct






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 30 '18 at 16:49









      Christopher ArmstrongChristopher Armstrong

      1,44832232




      1,44832232
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Use the raw property of the request https://pub.dartlang.org/documentation/aqueduct/latest/aqueduct/Request/raw.html



          Edit by CA:
          The request object is already present in a controller that extends from ResourceController or Controller and can simply be used as such:



          final remote_address = request.raw.connectionInfo.remoteAddress.address;





          share|improve this answer


























          • Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

            – Christopher Armstrong
            Dec 31 '18 at 0:44





















          -1














          You can’t bind it, but you access it the same way. The request is available as a property of a resource controller, so it’s available in every method.






          share|improve this answer
























          • Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

            – Christopher Armstrong
            Jan 2 at 12:30











          • This does not seem to answer the original question....

            – piet.t
            Jan 2 at 13:59











          • It was meant as a comment to the other answer if you can move it

            – Joe Conway
            Jan 2 at 14:02











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53979553%2fhow-to-get-client-remote-ip-address-in-resource-controller%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Use the raw property of the request https://pub.dartlang.org/documentation/aqueduct/latest/aqueduct/Request/raw.html



          Edit by CA:
          The request object is already present in a controller that extends from ResourceController or Controller and can simply be used as such:



          final remote_address = request.raw.connectionInfo.remoteAddress.address;





          share|improve this answer


























          • Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

            – Christopher Armstrong
            Dec 31 '18 at 0:44


















          1














          Use the raw property of the request https://pub.dartlang.org/documentation/aqueduct/latest/aqueduct/Request/raw.html



          Edit by CA:
          The request object is already present in a controller that extends from ResourceController or Controller and can simply be used as such:



          final remote_address = request.raw.connectionInfo.remoteAddress.address;





          share|improve this answer


























          • Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

            – Christopher Armstrong
            Dec 31 '18 at 0:44
















          1












          1








          1







          Use the raw property of the request https://pub.dartlang.org/documentation/aqueduct/latest/aqueduct/Request/raw.html



          Edit by CA:
          The request object is already present in a controller that extends from ResourceController or Controller and can simply be used as such:



          final remote_address = request.raw.connectionInfo.remoteAddress.address;





          share|improve this answer















          Use the raw property of the request https://pub.dartlang.org/documentation/aqueduct/latest/aqueduct/Request/raw.html



          Edit by CA:
          The request object is already present in a controller that extends from ResourceController or Controller and can simply be used as such:



          final remote_address = request.raw.connectionInfo.remoteAddress.address;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 2 at 14:10









          Christopher Armstrong

          1,44832232




          1,44832232










          answered Dec 30 '18 at 17:42









          Joe ConwayJoe Conway

          68857




          68857













          • Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

            – Christopher Armstrong
            Dec 31 '18 at 0:44





















          • Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

            – Christopher Armstrong
            Dec 31 '18 at 0:44



















          Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

          – Christopher Armstrong
          Dec 31 '18 at 0:44







          Ok, so I understood that I can create a middleware controller, override the handle function, use request.raw.connectionInfo() to get the remote IP, and attach it to request.attachments. But how can I access the request.attachments properties in the subsequent resource controller function annotated by @Operation.post? Can I somehow bind to it through @Bind annotation?

          – Christopher Armstrong
          Dec 31 '18 at 0:44















          -1














          You can’t bind it, but you access it the same way. The request is available as a property of a resource controller, so it’s available in every method.






          share|improve this answer
























          • Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

            – Christopher Armstrong
            Jan 2 at 12:30











          • This does not seem to answer the original question....

            – piet.t
            Jan 2 at 13:59











          • It was meant as a comment to the other answer if you can move it

            – Joe Conway
            Jan 2 at 14:02
















          -1














          You can’t bind it, but you access it the same way. The request is available as a property of a resource controller, so it’s available in every method.






          share|improve this answer
























          • Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

            – Christopher Armstrong
            Jan 2 at 12:30











          • This does not seem to answer the original question....

            – piet.t
            Jan 2 at 13:59











          • It was meant as a comment to the other answer if you can move it

            – Joe Conway
            Jan 2 at 14:02














          -1












          -1








          -1







          You can’t bind it, but you access it the same way. The request is available as a property of a resource controller, so it’s available in every method.






          share|improve this answer













          You can’t bind it, but you access it the same way. The request is available as a property of a resource controller, so it’s available in every method.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 31 '18 at 13:37









          Joe ConwayJoe Conway

          68857




          68857













          • Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

            – Christopher Armstrong
            Jan 2 at 12:30











          • This does not seem to answer the original question....

            – piet.t
            Jan 2 at 13:59











          • It was meant as a comment to the other answer if you can move it

            – Joe Conway
            Jan 2 at 14:02



















          • Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

            – Christopher Armstrong
            Jan 2 at 12:30











          • This does not seem to answer the original question....

            – piet.t
            Jan 2 at 13:59











          • It was meant as a comment to the other answer if you can move it

            – Joe Conway
            Jan 2 at 14:02

















          Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

          – Christopher Armstrong
          Jan 2 at 12:30





          Ok, got it. as I'm extending from Controller, the handle method is executed which has the request, I can use it as such in my controller directly. Thanks a lot.

          – Christopher Armstrong
          Jan 2 at 12:30













          This does not seem to answer the original question....

          – piet.t
          Jan 2 at 13:59





          This does not seem to answer the original question....

          – piet.t
          Jan 2 at 13:59













          It was meant as a comment to the other answer if you can move it

          – Joe Conway
          Jan 2 at 14:02





          It was meant as a comment to the other answer if you can move it

          – Joe Conway
          Jan 2 at 14:02


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53979553%2fhow-to-get-client-remote-ip-address-in-resource-controller%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'