mirror of
				https://github.com/therootcompany/golib.git
				synced 2025-10-30 20:52:53 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			403 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			403 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package https
 | |
| 
 | |
| import (
 | |
| 	"net"
 | |
| 	"net/http"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // NewHTTPClient creates a new http client with reasonable and safe defaults
 | |
| func NewHTTPClient() *http.Client {
 | |
| 	transport := &http.Transport{
 | |
| 		Dial: (&net.Dialer{
 | |
| 			Timeout: 10 * time.Second,
 | |
| 		}).Dial,
 | |
| 		TLSHandshakeTimeout: 5 * time.Second,
 | |
| 	}
 | |
| 	client := &http.Client{
 | |
| 		Timeout:   time.Second * 5,
 | |
| 		Transport: transport,
 | |
| 	}
 | |
| 	return client
 | |
| }
 |