anchor.diff:              CDMIVersions = string:tokens(L, ","),
               not lists:member(?CDMI_VERSION, CDMIVersions)
       end,
  -    {Valid, Req, Pid}.
  +    {Valid, Req, State}.
  +
  +%% Has the resource has moved, permanently?
  +%% If the request asks for a cdmi-container or cdmi-domain, and
  +%% the URL does not end with a slash, it has moved permanently.
  +moved_permanently(Req, State) ->
  +    {_Pid, Moved} = State,
  +    {Moved, Req, State}.
  +
  +%% Did the resource exist once upon a time?
  +%% For non-CDMIobject types that lack a trailing slash,
  +%% does that resource exist with a trailing slash?
  +previously_existed(Req, State) ->
  +    {Pid, _Opts} = State,
  +    lager:info("previously_existed"),
  +    {Path, _} = cowboy_req:path(Req),
  +    {BinaryAcceptHeader, _} = cowboy_req:header(<<?ACCEPT_HEADER>>, Req, error),
  +    Response = needs_a_slash(binary_to_list(Path),
  +                             State,
  +                             binary_to_list(BinaryAcceptHeader)),
  +    lager:info("previously_existed Response: ~p", [Response]),
  +    State2 = {Pid, Response},
  +    R = case Response of
  +            {true, _} -> true;
  +            false     -> false
  +        end,
  +    {R, Req, State2}.
   
   %% Does the resource exist?
  -resource_exists(Req, Pid) ->
  +resource_exists(Req, State) ->
  +    {Pid, _Opts} = State,
  +    lager:info("resource_exists"),
       {Path, _} = cowboy_req:path(Req),
       Uri = string:substr(binary_to_list(Path), 6),
       Response = case nebula2_riak:search(Pid, Uri) of
  
positive.code:                        pooler:return_member(riak_pool, Pid),
                         false
                 end,
      {Response, Req, Pid}.
      
  %% if pooler says no members, kick back a 503. I
  %% do this here because a 503 seems to me the most
  %% appropriate response if database connections are
  %% <b>currently</b> unavailable.
  service_available(Req, error_no_members) ->
      {false, Req, undefined};
  service_available(Req, Pid) ->
      Available = case nebula2_riak:ping(Pid) of
          true -> true;
          _ -> false
      end,
      {Available, Req, Pid}.
  
  to_cdmi_capability(Req, Pid) ->
      to_cdmi_object(Req, Pid).
  
  to_cdmi_container(Req, Pid) ->
      to_cdmi_object(Req, Pid).
  
  to_cdmi_object(Req, Pid) ->
      {Path, _} = cowboy_req:path(Req),
      Uri = string:substr(binary_to_list(Path), 6),
      Response = case nebula2_riak:search(Pid, Uri) of
  
negative.code:          content_types_provided/2,
           from_cdmi_capability/2,
           from_cdmi_container/2,
           from_cdmi_domain/2,
           from_cdmi_object/2,
           forbidden/2,
           is_authorized/2,
           malformed_request/2,
           moved_permanently/2,
           previously_existed/2,
           resource_exists/2,
           rest_init/2,
           service_available/2,
           to_cdmi_capability/2,
           to_cdmi_container/2,
           to_cdmi_domain/2,
           to_cdmi_object/2]).
  
  init(_, _Req, _Opts) ->
  