虛假回覆本地您可以使用Jaqen,這是一個非常輕的服務器,用於測試依賴於API的腳本。
你可以設置任何你想要它直接回應的要求,所以它可能就是你正在尋找的。
例如:
# Console request to a Jaqen instance listening at localhost:9000
$ curl 'http://localhost:9000/echo.json?foo=bar&data\[name\]=Jaqen&data\[v\]=1.0.0' -i
=> HTTP/1.1 200 OK
=> Content-Type: application/json
...
=> {"foo":"bar","data":{"name":"Jaqen","v":"1.0.0"}}
有幾種方法來告訴它該做什麼,也靜態文件允許裝載測試頁面和資源,檢查出documentation更多。
它建立在node.js之上,所以它很容易在本地安裝和使用。
# To install it (once you have node.js):
$ npm install -g jaqen
# To run it just type 'jaqen' on the console:
$ jaqen
=> Jaqen v1.0.0 is listening on port 9000.
=> Press Ctl+C to stop the server.
就是這樣!
來源
2014-07-15 01:20:34
404
如果您顯示了一些代碼,則可以更容易地解決您的問題。 – PiotrWolkowski