diff --git a/fetch/main.go b/fetch/main.go index 78fb713..beb2fe8 100644 --- a/fetch/main.go +++ b/fetch/main.go @@ -15,15 +15,25 @@ func main() { c := http.Client{ Transport: &fetch.Transport{}, } - resp, err := c.Post( + req, err := http.NewRequest( + "POST", "https://httpbin.org/anything", - "application/json", strings.NewReader(`{"test":"test"}`), ) if err != nil { fmt.Println(err) return } + /* + ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*200) + defer cancel() + req = req.WithContext(ctx) + */ + resp, err := c.Do(req) + if err != nil { + fmt.Println(err) + return + } defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) if err != nil {