h2non / gentleman

Plugin-driven, extensible HTTP client toolkit for Go

Home Page:https://pkg.go.dev/github.com/h2non/gentleman?tab=doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alerts for too many middlewares

gonejack opened this issue · comments

package main

import (
	"gopkg.in/h2non/gentleman.v2"
)

func main() {
	var client = gentleman.New()
	var src chan []byte
	for dat := range src {
		rq := client.URL("url").Post().JSON(dat)
		rq.Do()
		//....
	}
}

I know this is not gentleman's mistake but mine writing client.URL("url").Post() instead of client.Post().URL("url")

But it took me days to trace this CPU high usage issue.

Is there any way to prevent people falling into this trouble anymore, could gentleman returning an error when there are too many middlewares.