mirror of
https://github.com/cubixle/l1.git
synced 2026-04-30 10:58:41 +01:00
more things
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package l1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func DefaultHTTPTester(target string) *Result {
|
||||
result := &Result{}
|
||||
client := http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, target, nil)
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
return result
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
rsp, err := client.Do(req)
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
}
|
||||
result.CompletedIn = time.Since(startTime).Seconds()
|
||||
result.StatusCode = rsp.StatusCode
|
||||
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user