anchor.diff:  %% @end
   -spec init([]) -> {ok, undefined}.
   init([]) -> 
  -	 %% start this in the make file somehow
       {ok, undefined}.
   
   %% @doc
   %% Function: allowed_methods/2
  -%% Purpose: init function used to fetch path information from webmachine dispatcher.
  -%% Returns: {ok, undefined}
  -%% @end
  +%% Purpose: Used to define what methods are allowed one the given URI's.
  +%% Returns: {List, ReqData, State}, where list is the allowed methods for the given URI. 
  +%% @end
  +-spec allowed_methods(ReqData::term(),State::term()) -> {list(), term(), term()}.
   
   allowed_methods(ReqData, State) ->
   	erlang:display(parse_path(wrq:path(ReqData))),
  
positive.code: 				ResId ->
  					ResAdded = add_field(UserAdded,"resource_id",ResId)
  			end,
  			%display:erlang(ResAdded),
  			case erlastic_search:index_doc(?INDEX, "stream", ResAdded) of	
  				{error, Reason} -> {{error, Reason}, ReqData, State};
  				{ok,List} -> erlang:display(convert_binary_to_string(json_encode(List))), 
  							 {convert_binary_to_string(json_encode(List)), ReqData, State}
  			end;
  		true ->
  			process_search(ReqData,State)	
  	end.
  
  process_search(ReqData, State) ->
  	erlang:display("search request"),
  
negative.code: 				end
  	end.
  
  %% @doc
  %% Function: is_search/1
  %% Purpose: Used to decied if the URI specifys a search
  %% Returns: True if URI specifys a search, false otherwise
  %% @end
  -spec is_search(ReqData::term()) -> boolean().
  
  is_search(ReqData) ->
  	URIList = string:tokens(wrq:path(ReqData), "/"),
  	IsSearch = (string:sub_string(lists:nth(length(URIList),URIList),1,7) == "_search").
  
  %% @doc
  %% Function: json_handler/2
  %% Purpose: Used to get the json object from the request
  %% Returns: {Json,ReqData,State}
  %% @end
  -spec json_handler(ReqData::term(),State::term()) -> {boolean(), term(), term()}.
  
  json_handler(ReqData, State) ->
  	[{Value,_ }] = mochiweb_util:parse_qs(wrq:req_body(ReqData)), 
  	{Value, ReqData, State}.
  
  %% @doc
  %% Function: is_query_empty/1
  %% Purpose: Used to decied if the respond from erlastic search found no value
  %% Returns: True if URI specifys a search, false otherwise
  %% @end
  -spec is_query_empty(Respons::term()) -> boolean().
  
  is_query_empty({struct,[{_,_},{_,_},{_,{struct,[{_,_},{_,_},{_,0}]}},_]}) ->
  	true;
  is_query_empty(_) ->
  	false.
  
  
  
  create_update(Stream) ->
  	"{\n\"doc\" : " ++ Stream ++ "\n}".
  
  
  
  add_field(Stream,FieldName,FieldValue) ->
  	string:substr(Stream,1,length(Stream)-2) ++ ",\n" ++ FieldName ++ " : " ++ FieldValue ++ "\n}".
  	
  
  
  %% @doc
  %% Function: merge_lists/2
  