Go 的 HTTP 開發包:Fluent
Fluent 是 Go 語言的 HTTP 客戶端開發包,支持超時、重試等。
示例代碼:
package main
import (
"fmt"
"github.com/lafikl/fluent"
"time"
)
func main() {
req := fluent.New()
req.Post("http://example.com").
InitialInterval(time.Duration(time.Millisecond)).
Json([]int{1, 3, 4}).
Retry(3)
res, err := req.Send()
if err != nil {
fmt.Println(err)
}
fmt.Println("donne ", res)
// They can be separated if you don't like chaining ;)
// for example:
// req.Get("http://example.com")
// req.Retry(3)
}
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!