mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-06 08:17:42 -05:00
24 lines
433 B
Go
24 lines
433 B
Go
package checks
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// NewHTTPCheck checks the reachability of a http server.
|
|
func NewHTTPCheck(url string) func(context.Context) error {
|
|
return func(_ context.Context) error {
|
|
c := http.Client{
|
|
Timeout: 3 * time.Second,
|
|
}
|
|
resp, err := c.Get(url)
|
|
if err != nil {
|
|
return fmt.Errorf("could not connect to http server: %v", err)
|
|
}
|
|
_ = resp.Body.Close()
|
|
return nil
|
|
}
|
|
}
|