20160603
介紹幾款 http 工具及服務(wù)
cURL
cURL 很強悍, 沒有干不了的事, 就是麻煩了些.
curl -I https://basecamp.com/
HTTP/1.1 200 OK
Server: openresty
Content-Type: text/html
Content-Length: 18142
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
Accept-Ranges: bytes
可以看到 basecamp用了openresty.
httpie
httpie 是個不錯的代替 cURL 的工具.
顏值高, 命令更簡單, 默認輸入和輸出都是json格式.
curl的一個 -H "Content-Type: application/json"
就感覺到了郁悶.
http -h https://basecamp.com/
http -b https://basecamp.com/
http -h get http://httpbin.org/get
http -h post http://httpbin.org/post
http -h delete http://httpbin.org/delete
http -h put http://httpbin.org/put
Ngrok
ngrok 可以把本地服務(wù)映射到外部網(wǎng)絡(luò), 在做微信開發(fā)的時候異常方便.
ittun是在大陸搭建的Ngrok服務(wù)器, 可以下載ittun的cfg文件:
# ngrok.cfg
server_addr: "tunnel.mobi:44433"
trust_host_root_certs: true
輸入下面命令
rails s 0.0.0.0 -p 8000
ngrok -subdomain=shooter -config=ngrok.cfg 8000
得到下面的輸出, 已經(jīng)齊活.
Tunnel Status online
Version 1.7/1.7
Forwarding http://shooter.ittun.com -> 127.0.0.1:8000
Forwarding https://shooter.ittun.com -> 127.0.0.1:8000
Web Interface 127.0.0.1:4040
# Conn 0
Avg Conn Time 0.00ms
就可以在 http://shooter.ittun.com
訪問本地了.
requestbin
requestbin 提供一個地址,可以接收任何HTTP請求,并把結(jié)果展現(xiàn)出來,用于檢查
HTTP客戶端發(fā)送的內(nèi)容或Webhook調(diào)試信息.
你可以試試大陸版的requestbin
json-server
json-server一行命令就提供RESTful接口,還支持cors和jsonp,特別好用.
你當然也可以試試 myjson
webscript.io
webscript.io 是個可以運行 lua script的服務(wù), 也可以執(zhí)行cron任務(wù).
zen 就是我用 lua 腳本寫的.我看到一個馬來西亞人
在webscript.io上寫了個簡單的 Telegram Bot.
lua并不難學, 有很多例子.
webscript 類似 Google的云函數(shù)服務(wù) 和 Amazon Lambda,
后兩者都允許在云端部署/執(zhí)行單個函數(shù).