anchor.diff:                      "Riak does not accept credentials over HTTP. Try HTTPS "
                       "instead.">>, ReqData), Ctx}
       end.
  +
  +-spec service_available(#wm_reqdata{}, context()) ->
  +    {boolean(), #wm_reqdata{}, context()}.
  +%% @doc Determine whether or not a connection to Riak
  +%%      can be established. Also, extract query params.
  +service_available(RD, Ctx0=#ctx{riak=RiakProps}) ->
  +    Ctx = riak_kv_wm_utils:ensure_bucket_type(RD, Ctx0, #ctx.bucket_type),
  +    case riak_kv_wm_utils:get_riak_client(RiakProps,
  +                                          riak_kv_wm_utils:get_client_id(RD)) of
  +        {ok, C} ->
  +            {true, RD, Ctx#ctx { client=C }};
  +        Error ->
  +            {false,
  +             wrq:set_resp_body(
  +               io_lib:format("Unable to connect to Riak: ~p~n", [Error]),
  +               wrq:set_resp_header(?HEAD_CTYPE, "text/plain", RD)),
  +             Ctx}
  +    end.
  +
   
   forbidden(RD, Ctx = #ctx{security=undefined}) ->
       {riak_kv_wm_utils:is_forbidden(RD), RD, Ctx};
  
positive.code: 
  -spec init(proplists:proplist()) -> {ok, context()}.
  %% @doc Initialize this resource.  This function extracts the
  %%      'prefix' and 'riak' properties from the dispatch args.
  init(Props) ->
      {ok, #ctx{
              bucket_type=proplists:get_value(bucket_type, Props)}}.
  
  is_authorized(ReqData, Ctx) ->
  
negative.code:          content_types_provided/2,
           encodings_provided/2,
           produce_preflist_body/2,
           malformed_request/2,
           service_available/2
          ]).
  
  -record(ctx, {
            client,     %% :: riak_client()             %% the store client
            riak,       %% local | {node(), atom()}     %% params for riak client
            bucket_type :: binary(),                    %% bucket type (from uri)
            bucket      :: binary(),                    %% Bucket name (from uri)
            key         :: binary(),                    %% Key (from uri)
  