var urlencode = require('urlencode');
var mockData = require('../json/mockDate.json');
exports=module.exports=function(logger,rest,settings){    

	function getJson(url,method){
		var backData={};
		for(var i=0;i<mockData.length;i++){
			var urlRegex=new RegExp(mockData[i].url,'g');
			if(urlRegex.test(url)){
				backData=mockData[i][method+'_data'];
				return backData;
			}
		}
		return backData;
	}

	function get(req,res,next){ 
		console.log(req.path);
		res.send(getJson(req.path,'get')); 	 
	}

	function post(req,res,next){
		console.log(req.path);
		res.send(getJson(req.path,'post')); 
	}

	function put(req,res,next){
		console.log(req.path);
		res.send(getJson(req.path,'put')); 
	}

	function patch(req,res,next){
		console.log(req.path);
		res.send(getJson(req.path,'patch')); 
	}

	function head(req,res,next){
		console.log(req.path);
		res.send(getJson(req.path,'head')); 
	}

	function del(req,res,next){ 
		console.log(req.path);
		res.send(getJson(req.path,'del')); 
	}

	return { 
		'get':get,
		'post':post,
		'put':put,
		'patch':patch,
		'head':head,
		'delete':del
	};
};

exports['@singleton']=true;
exports['@require']=['igloo/logger','utils/rest','igloo/settings'];