Commits

Anonymous committed 6aea72b

HTTP support for setting/using default bucket r/w/dw values (see #83)

Comments (0)

Files changed (2)

apps/riak_kv/src/riak_kv_util.erl

           proplists:get_value(Type, DefaultProps)} of
         {undefined, Val} -> Val;
         {Val, undefined} -> Val;
-        {Val, Val} -> Val
+        {Val1, _Val2} -> Val1
     end.
             
-                                                      
-
 expand_rw_value(Type, default, BucketProps, N) ->
     normalize_rw_value(get_default_rw_val(Type, BucketProps), N);    
 expand_rw_value(_Type, Val, _BucketProps, N) ->
     normalize_rw_value(Val, N).
 
 normalize_rw_value(RW, _N) when is_integer(RW) -> RW;
+normalize_rw_value(RW, N) when is_binary(RW) ->
+    normalize_rw_value(binary_to_atom(RW, utf8), N);
 normalize_rw_value(one, _N) -> 1;
 normalize_rw_value(quorum, N) -> erlang:trunc((N/2)+1);
 normalize_rw_value(all, N) -> N.

apps/riak_kv/src/riak_kv_wm_raw.erl

 malformed_rw_params(RD, Ctx) ->
     lists:foldl(fun malformed_rw_param/2,
                 {false, RD, Ctx},
-                [{#ctx.r, "r", "2"},
-                 {#ctx.w, "w", "2"},
-                 {#ctx.dw, "dw", "0"},
-                 {#ctx.rw, "rw", "2"}]).
+                [{#ctx.r, "r", "default"},
+                 {#ctx.w, "w", "default"},
+                 {#ctx.dw, "dw", "default"},
+                 {#ctx.rw, "rw", "default"}]).
 
 %% @spec malformed_rw_param({Idx::integer(), Name::string(), Default::string()},
 %%                          {boolean(), reqdata(), context()}) ->
              Ctx}
     end.
 
+normalize_rw_param("default") -> default;
 normalize_rw_param("one") -> one;
 normalize_rw_param("quorum") -> quorum;
 normalize_rw_param("all") -> all;