parent
dde89b72fa
commit
fc38ef6a3f
@ -0,0 +1,20 @@
|
||||
#coding=utf-8
|
||||
#
|
||||
require 'socket'
|
||||
|
||||
class ResponseIp
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def ip
|
||||
addr = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address rescue
|
||||
addr || ''
|
||||
end
|
||||
|
||||
def call(env)
|
||||
status, headers, body = @app.call(env)
|
||||
headers["X-response-ip"] = ip
|
||||
[status, headers, body]
|
||||
end
|
||||
end
|
Loading…
Reference in new issue