Skip to content

Commit

Permalink
Addressing issue #262
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco committed May 28, 2015
1 parent 9d35073 commit 4f6c0ae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
3 changes: 0 additions & 3 deletions kong/dao/cassandra/apis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ local function validate_target_url(value)
parsed_url.scheme = parsed_url.scheme:lower()
if parsed_url.scheme == "http" or parsed_url.scheme == "https" then
parsed_url.path = parsed_url.path or "/"

print(url.build(parsed_url))

return true, nil, { target_url = url.build(parsed_url)}
else
return false, "Supported protocols are HTTP and HTTPS"
Expand Down
13 changes: 8 additions & 5 deletions kong/kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,22 @@ function _M.exec_plugins_log()
-- Creating the log variable that will be serialized
local message = {
request = {
uri = ngx.var.request_uri,
request_uri = ngx.var.scheme.."://"..ngx.var.host..":"..ngx.var.server_port..ngx.var.request_uri,

This comment has been minimized.

Copy link
@subnetmarco

subnetmarco May 28, 2015

Author Member

In my tests ngx.var.uri and ngx.var.request_uri were the same thing, so I had to build the full URI using this concatentation.

querystring = ngx.req.get_uri_args(), -- parameters, as a table
method = ngx.req.get_method(), -- http method
headers = ngx.req.get_headers(),
size = ngx.var.request_length
},
response = {
status = ngx.status,
headers = ngx.resp.get_headers(),
size = ngx.var.body_bytes_sent
size = ngx.var.bytes_sent
},
authenticated_entity = ngx.ctx.authenticated_entity,
api = ngx.ctx.api,
ip = ngx.var.remote_addr,
status = ngx.status,
url = ngx.var.uri,
started_at = ngx.ctx.started_at
client_ip = ngx.var.remote_addr,
started_at = ngx.req.start_time() * 1000
}

ngx.ctx.log_message = message
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/proxy/realip_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("Real IP", function()
assert.truthy(json_str)

local log_message = cjson.decode(json_str)
assert.are.same("4.4.4.4", log_message.ip)
assert.are.same("4.4.4.4", log_message.client_ip)
assert.are.same(uuid, log_message.request.headers.file_log_uuid)
end)

Expand Down
8 changes: 4 additions & 4 deletions spec/plugins/logging_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("Logging Plugins", function()

-- Making sure it's alright
local log_message = cjson.decode(res)
assert.are.same("127.0.0.1", log_message.ip)
assert.are.same("127.0.0.1", log_message.client_ip)
end)

it("should log to UDP", function()
Expand All @@ -75,7 +75,7 @@ describe("Logging Plugins", function()

-- Making sure it's alright
local log_message = cjson.decode(res)
assert.are.same("127.0.0.1", log_message.ip)
assert.are.same("127.0.0.1", log_message.client_ip)
end)

it("should log to HTTP", function()
Expand All @@ -93,7 +93,7 @@ describe("Logging Plugins", function()
-- Making sure it's alright
assert.are.same("POST / HTTP/1.1", res[1])
local log_message = cjson.decode(res[7])
assert.are.same("127.0.0.1", log_message.ip)
assert.are.same("127.0.0.1", log_message.client_ip)
end)

it("should log to file", function()
Expand Down Expand Up @@ -124,7 +124,7 @@ describe("Logging Plugins", function()
assert.truthy(json_str)

local log_message = cjson.decode(json_str)
assert.are.same("127.0.0.1", log_message.ip)
assert.are.same("127.0.0.1", log_message.client_ip)
assert.are.same(uuid, log_message.request.headers.file_log_uuid)
end)

Expand Down

0 comments on commit 4f6c0ae

Please sign in to comment.