Browse Source

new nitro:q impl by @dhull

Namdak Tonpa 6 years ago
parent
commit
c53d97720e
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/nitro.erl

+ 6 - 3
src/nitro.erl

@@ -5,9 +5,12 @@
 -behaviour(application).
 -export([start/2, stop/1, init/1]).
 
-q(Key) -> q(Key,get(Key)).
-q(_,undefined) -> [];
-q(_,Val) -> Val.
+q(Key) -> q(Key, []).
+q(Key, Default) ->
+  case get(Key) of
+    undefined -> Default;
+    Value     -> Value
+  end.
 
 qc(Key) -> CX = get(context), qc(Key,CX#cx.req).
 qc(Key,Req) -> proplists:get_value(nitro:to_binary(Key),cowboy_req:parse_qs(Req)).