【问题标题】:Find remote address of Netty HttpRequest查找 Netty HttpRequest 的远程地址
【发布时间】:2018-08-19 10:42:09
【问题描述】:

我正在使用 netty 并尝试定义一些映射 using this library。 但是我不知道如何从 HttpRequest 中获取用户的远程地址。

这是示例代码:

public class TestHandler extends AbstractHttpHandler {
@Path("/ping")
@GET
public void testGet(HttpRequest httpRequest, HttpResponder responder) {
    // remote address?
    responder.sendString(HttpResponseStatus.OK, "OK");
}

}

【问题讨论】:

  • 我通过管道添加ChannelHandler解决了这个问题,在那里得到了远程地址并将其放入请求头中。

标签: jax-rs netty


【解决方案1】:

我不能告诉你你正在使用的库,但通常你会使用channel.remoteAddress() 来获取远程对等点的地址。

【讨论】:

    猜你喜欢
    • 2012-08-05
    • 2016-03-09
    • 1970-01-01
    • 2014-08-24
    • 2020-05-14
    • 1970-01-01
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多