gorequests

Package gorequests send http request with human style. for send GET request: for send POST request: for send http upload request for send json request request with timeout request with context request with no redirect

APACHE-2.0 License

Stars
4

gorequests

Simple and easy-to-use go http client, supports cookies, streaming calls, custom logs and other functions

Install

go get github.com/chyroc/gorequests

Usage

Simple Send Request

func main() {
	text, err := gorequests.New(http.MethodGet, "https://jsonplaceholder.typicode.com/todos/1").Text()
	if err != nil {
		panic(err)
	}
	fmt.Println("text", text)
}

Send Request With Cookie

func main() {
	session := gorequests.NewSession("/tmp/gorequests-session.txt")
	text, err := session.New(http.MethodGet, "https://jsonplaceholder.typicode.com/todos/1").Text()
	if err != nil {
		panic(err)
	}
	fmt.Println("text", text)
}

Request Factory

func main() {
    fac := gorequests.NewFactory(
        gorequests.WithLogger(gorequests.NewDiscardLogger()),
    )
	text, err := fac.New(http.MethodGet, "https://jsonplaceholder.typicode.com/todos/1").Text()
	if err != nil {
		panic(err)
	}
	fmt.Println("text", text)
}