lib/doraemon/proxy_server.rb in doraemon-1.0.3 vs lib/doraemon/proxy_server.rb in doraemon-1.0.4
- old
+ new
@@ -34,10 +34,11 @@
_params = begin JSON.parse(_req.body) rescue _req.body end
_result = begin JSON.parse(_resp.body) rescue {} end
begin
- _result = eval(File.read(File.join(@root, api_list[_req.path])))
+ _api_path = File.join(@root, api_list[_req.path])
+ _result = eval(File.read(_api_path)) if File.exist?(_api_path)
rescue
_result = {
"code": -1,
"msg": "#{_req.path} 处理错误"
}
\ No newline at end of file