Skip to content

Instantly share code, notes, and snippets.

@yehohanan7
Created April 24, 2018 19:07
Show Gist options
  • Save yehohanan7/dbfb59eedee429dfb21a11f79a554445 to your computer and use it in GitHub Desktop.
Save yehohanan7/dbfb59eedee429dfb21a11f79a554445 to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"fmt"
"net"
"net/http"
"net/http/httputil"
"strconv"
)
func main() {
tcpConn, _ := net.Dial("tcp", "127.0.0.1:4000")
conn := httputil.NewClientConn(tcpConn, nil)
for i := 0; i < 10; i++ {
req, _ := http.NewRequest("POST", "/candidates", bytes.NewBuffer([]byte(fmt.Sprintf(`{ "id": "%v"}`, "id"+strconv.Itoa(i)))))
req.Header.Set("Content-Type", "application/json")
resp, err := conn.Do(req)
if err != nil {
panic(err)
}
fmt.Println(resp)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment