-
Notifications
You must be signed in to change notification settings - Fork 5
/
nginx.conf
45 lines (34 loc) · 1.42 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
events {
worker_connections 1024;
}
env LAUNCHDARKLY_SDK_KEY;
env LAUNCHDARKLY_FLAG_KEY;
http {
resolver 8.8.8.8;
lua_package_path ";;/usr/local/openresty/nginx/scripts/?.lua;";
init_worker_by_lua_file scripts/shared.lua;
server {
location / {
default_type text/html;
content_by_lua_block {
local os = require("os")
local ld = require("launchdarkly_server_sdk")
local client = require("shared")
local get_from_env_or_default = require("get_from_env_or_default")
-- Set MY_FLAG_KEY to the feature flag key you want to evaluate. To specify the flag key as
-- an environment variable instead, set LAUNCHDARKLY_FLAG_KEY using '--env LAUNCHDARKLY_FLAG_KEY=my-boolean-flag-key'
-- as a 'docker run' argument.
local MY_FLAG_KEY = ""
local user = ld.makeContext({
user = {
key = "example-user-key",
name = "Sandy"
}
})
local flag_key = get_from_env_or_default("LAUNCHDARKLY_FLAG_KEY", MY_FLAG_KEY)
local flag_value = client:boolVariation(user, flag_key, false)
ngx.say("<p>The " .. flag_key .. " feature flag evaluates to " .. tostring(flag_value) .. ".</p>")
}
}
}
}