status/scanner/httpSuccess.go

19 lines
327 B
Go
Raw Normal View History

2023-09-30 16:56:37 +00:00
package scanner
2023-09-30 15:19:02 +00:00
import "net/http"
2023-09-30 16:19:41 +00:00
func Request(url string) (bool, string) {
2023-09-30 15:19:02 +00:00
req, err := http.Get(url)
if err != nil {
// `req` could be `nil` so we need this check
2023-09-30 16:19:41 +00:00
return false, ""
2023-09-30 15:19:02 +00:00
}
2023-09-30 16:23:26 +00:00
// if code is 200-299
if req.StatusCode >= 200 && req.StatusCode <= 299 {
return true, req.Status
2023-09-30 15:19:02 +00:00
}
2023-09-30 16:23:26 +00:00
return false, req.Status
2023-09-30 15:19:02 +00:00
}