imroc / req

Simple Go HTTP client with Black Magic

Home Page:https://req.cool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I set a timeout for a get or post request? For example, if no data is returned within 3 seconds, it is considered a failure

2622594863 opened this issue · comments

How do I set a timeout for a get or post request? For example, if no data is returned within 3 seconds, it is considered a failure. Here's my code

rsp, err := client.R().Post(url + "/Login/Get")

Thank you. I found it. Thanks for your trouble
client := req.C()
client.SetTimeout(5 * time.Second)