增加了一个查看服务器内网ip的middleware,利于以后分析问题,headers为X-Response-Ip
This commit is contained in:
parent
dde89b72fa
commit
fc38ef6a3f
|
@ -3,6 +3,7 @@ require File.expand_path('../boot', __FILE__)
|
|||
require 'rails/all'
|
||||
require 'sprockets/railtie'
|
||||
require 'elasticsearch/model'
|
||||
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||
|
@ -83,9 +84,11 @@ module RedmineApp
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
config.wechat_srcs = ['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js']
|
||||
|
||||
config.before_initialize do
|
||||
config.middleware.use ::ResponseIp
|
||||
end
|
||||
|
||||
config.after_initialize do
|
||||
|
|
30
db/schema.rb
30
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160725091759) do
|
||||
ActiveRecord::Schema.define(:version => 20160729124833) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -52,9 +52,24 @@ ActiveRecord::Schema.define(:version => 20160725091759) do
|
|||
add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token"
|
||||
add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id"
|
||||
|
||||
create_table "applied_messages", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "applied_id"
|
||||
t.string "applied_type"
|
||||
t.integer "viewed", :default => 0
|
||||
t.integer "status", :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "name"
|
||||
t.integer "applied_user_id"
|
||||
t.integer "role"
|
||||
t.integer "project_id"
|
||||
end
|
||||
|
||||
create_table "applied_projects", :force => true do |t|
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "role", :default => 0
|
||||
end
|
||||
|
||||
create_table "apply_add_schools", :force => true do |t|
|
||||
|
@ -577,9 +592,9 @@ ActiveRecord::Schema.define(:version => 20160725091759) do
|
|||
t.integer "excellent_option", :default => 0
|
||||
t.integer "is_copy", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "syllabus_id"
|
||||
t.string "invite_code"
|
||||
t.string "qrcode"
|
||||
t.integer "syllabus_id"
|
||||
end
|
||||
|
||||
add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true
|
||||
|
@ -1106,9 +1121,10 @@ ActiveRecord::Schema.define(:version => 20160725091759) do
|
|||
end
|
||||
|
||||
create_table "member_roles", :force => true do |t|
|
||||
t.integer "member_id", :null => false
|
||||
t.integer "role_id", :null => false
|
||||
t.integer "member_id", :null => false
|
||||
t.integer "role_id", :null => false
|
||||
t.integer "inherited_from"
|
||||
t.integer "is_current", :default => 1
|
||||
end
|
||||
|
||||
add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id"
|
||||
|
@ -1539,6 +1555,8 @@ ActiveRecord::Schema.define(:version => 20160725091759) do
|
|||
t.integer "boards_reply_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "hot", :default => 0
|
||||
t.string "invite_code"
|
||||
t.string "qrcode"
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
|
|
@ -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