File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
examples/feature_flag_demo/lib Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ defmodule FeatureFlagDemo do
76
76
{ :ok , % { enabled: false } } ->
77
77
IO . puts ( "Feature flag '#{ flag } ' is DISABLED" )
78
78
79
+ { :ok , % { enabled: variant , payload: payload } } when is_binary ( variant ) ->
80
+ IO . puts ( "Feature flag '#{ flag } ' is ENABLED with variant: #{ variant } " )
81
+ if payload , do: IO . puts ( "Payload: #{ inspect ( payload ) } " )
82
+
79
83
{ :error , % { status: 403 } } ->
80
84
IO . puts ( """
81
85
Error: Authentication failed (403 Forbidden)
@@ -98,15 +102,12 @@ defmodule FeatureFlagDemo do
98
102
""" )
99
103
100
104
{ :error , reason } ->
101
- IO . puts ( "Error checking feature flag : #{ inspect ( reason ) } " )
105
+ IO . puts ( "Error: #{ inspect ( reason ) } " )
102
106
end
103
107
end
104
108
105
- defp parse_json ( nil ) , do: % { }
106
- defp parse_json ( json ) when is_binary ( json ) do
107
- case Jason . decode ( json ) do
108
- { :ok , result } -> result
109
- { :error , _ } -> % { }
110
- end
111
- end
109
+ defp parse_json ( nil ) , do: nil
110
+ defp parse_json ( "" ) , do: nil
111
+ defp parse_json ( json ) when is_binary ( json ) , do: Jason . decode! ( json )
112
+ defp parse_json ( value ) , do: value
112
113
end
You can’t perform that action at this time.
0 commit comments