Module: Webhookdb::Platform
- Defined in:
- lib/webhookdb/platform.rb
Constant Summary collapse
- PLATFORM_USER_AGENT_HTTP =
"HTTP_WHDB_PLATFORM_USER_AGENT"
- CLI_USER_AGENT_HTTP =
"HTTP_WHDB_USER_AGENT"
- USER_AGENT_HTTP =
"HTTP_USER_AGENT"
- HEADERS =
[ PLATFORM_USER_AGENT_HTTP, CLI_USER_AGENT_HTTP, USER_AGENT_HTTP, ].freeze
Class Method Summary collapse
-
.platform_user_agent(env) ⇒ Object
Return the value of the platform UA header.
-
.user_agent(env) ⇒ Object
Return the user agent in the env.
Class Method Details
.platform_user_agent(env) ⇒ Object
Return the value of the platform UA header. For WASM, this is the browser’s user agent. For a binary, this is empty.
16 17 18 |
# File 'lib/webhookdb/platform.rb', line 16 def self.platform_user_agent(env) return env[PLATFORM_USER_AGENT_HTTP] || "" end |
.user_agent(env) ⇒ Object
Return the user agent in the env. This should be the CLI user agent, though it may also be a browser in WASM depending on the browser.
23 24 25 26 |
# File 'lib/webhookdb/platform.rb', line 23 def self.user_agent(env) values = HEADERS.map { |h| env[h] } return values.find(&:present?) || "" end |