Skip to content

Commit

Permalink
Add ExampleHTTPCache.
Browse files Browse the repository at this point in the history
  • Loading branch information
toomore committed May 22, 2015
1 parent 35fe07f commit eabf0d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions utils/tempfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ func TestHTTPCache(t *testing.T) {
hccp950 := NewHTTPCache(dir, "cp950")
hccp950.Get("http://toomore.net/", false)
}

// 目前可以支援 http.Get / http.PostForm 取得資料並儲存
func ExampleHTTPCache() {
hc := NewHTTPCache("/run/shm/", "utf8") // linux

ex1, _ := hc.Get("http://httpbin.org/get", false)
ex2, _ := hc.Get("http://httpbin.org/get?q=%d", true)
ex3, _ := hc.PostForm("http://httpbin.org/post", url.Values{"name": {"Toomore"}})

fmt.Printf("%s %s %s", ex1, ex2, ex3)
}

0 comments on commit eabf0d3

Please sign in to comment.