airlift / drift

An annotation-based Java library for creating Thrift serializable types and services.
Apache License 2.0
242 stars 92 forks source link

How to get the IP address of the client? #109

Closed jiangxuelei closed 5 years ago

jiangxuelei commented 5 years ago

I think ServerInvokeRequest should be extended. For example, add a ChannelHandlerContext field?

electrum commented 5 years ago

We probably want to expose context object similar to how @ThriftHeader is used. The API for this is tricky since the context is inherently transport specific.

For example, address could be done like this:

@ThriftMethod
void test(@ThriftContext("clientAddress") HostAndPort address);

I see a few options for the type of the context object:

jiangxuelei commented 5 years ago

Thank for reply. Version 1.18 can solve this problem? @electrum

electrum commented 5 years ago

No, it’s not implemented yet.