anchor.diff:  %% Internal functions
   %% ====================================================================
   
  +%% Get news
   get_from_db(Req) ->
   	Id = get_id(Req),
  -	case Id of
  -		0 ->
  -			Resp = mnesia_news:get_all_news();				
  +	case  Id of
  +		{fail, Error} ->
  +			 Error;
  +		_ when Id =< 0 ->
  +			 Resp = mnesia_news:get_all_news(),				
  +			 convert_response(Resp);
   		_ ->
  -			Resp = mnesia_news:get_news(Id)
  -	end,
  +			 Resp = mnesia_news:get_news(Id),
  +			 convert_response(Resp)
  +	end.
  +
  +convert_response(Resp)->
   	case Resp of
   		{atomic, Result} ->
   			Responce = lists:reverse(convert_news(Result, [])),			
  
positive.code: 	{[{<<"application/json">>, create_paste}],Req, State}.
  
  delete_resource(Req, State) ->
  	Id = get_id(Req),
  	Result = mnesia_news:delete_news(Id),
  	Body = result_to_json(Result),
  	cowboy_req:reply(200, #{}, Body, Req),
  	{ok, Req, State}.
  
  create_paste(Req, State) ->
  	
  
negative.code: 		{aborted, Reason} ->
  			jsx:encode([{<<"error">>, Reason}])
  	end.
  
  %% Save news
  save_to_db(Req) ->
  	Content = get_content(Req),
  	case validate(Content) of
  		{fail, Error} ->
  			Error;
  		_ ->
  			Escaped = escape_html_chars(Content),
  			Result = mnesia_news:create_news(Escaped),
  			result_to_json(Result)
  	end.
  
  %% Update news
  update_db(Req) ->
  	case Id = get_id(Req) of
  		{fail, Error} ->
  			Error;
  		_ when Id > 0 ->
  			Content = get_content(Req),
  			case validate(Content) of
  				{fail, Error} ->
  					Error;
  				_ ->
  					Escaped = escape_html_chars(Content),
  					Result = mnesia_news:update_news(Id, Escaped),
  					result_to_json(Result)
  			end;
  		_ -> 
  			<<"{\"error\": \"Empty news_id path variable.\"}">>
  	end.
  
  %% Validate html
  validate(Content) ->
  	case validate_html(Content) of
  		false -> 
  			{fail, jsx:encode([{<<"error">>, <<"Not valid html.">>}])};
  		true -> true
  	end.
  
  %% Convert responce to json
  