Skip to content

Commit

Permalink
[user-agent] handle missing APIcast module
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Dec 18, 2017
1 parent 226ee12 commit cd9b602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gateway/conf.d/apicast.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_by_lua $user_agent 'return require("apicast.user_agent")()';
set_by_lua_block $deployment {
local user_agent = require('apicast.user_agent')
return user_agent.platform() .. '+' .. user_agent.deployment()
return string.format('%s+%s', user_agent.platform(), user_agent.deployment())
}

# TODO: enable in the future when we support SSL
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/apicast/user_agent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local ffi = require 'ffi'
local env = require 'resty.env'

local setmetatable = setmetatable
local format = string.format

local _M = {
_VERSION = require('apicast.version')
Expand All @@ -15,7 +16,7 @@ end
-- User-Agent: Mozilla/<version> (<system-information>) <platform> (<platform-details>) <extensions>

function _M.call()
return 'APIcast/' .. _M._VERSION .. ' (' .. _M.system_information() .. ') ' .. (_M.platform() or '')
return format('APIcast/%s (%s) %s', _M._VERSION, _M.system_information(), _M.platform() or 'Unknown')
end

function _M.system_information()
Expand Down

0 comments on commit cd9b602

Please sign in to comment.