How to get client remote ip address in resource controller
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
add a comment |
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
add a comment |
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
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
dart aqueduct
asked Dec 30 '18 at 16:49
Christopher ArmstrongChristopher Armstrong
1,44832232
1,44832232
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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;
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
add a comment |
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
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
add a comment |
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;
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
add a comment |
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;
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;
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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