Use contants from http package.
This commit is contained in:
parent
7ed4ae2f8c
commit
05a9350e57
16 changed files with 68 additions and 62 deletions
|
@ -132,7 +132,7 @@ func checkBackend(currentBackend *BackendHealthCheck) {
|
|||
|
||||
func (backend *BackendHealthCheck) newRequest(serverURL *url.URL) (*http.Request, error) {
|
||||
if backend.Port == 0 {
|
||||
return http.NewRequest("GET", serverURL.String()+backend.Path, nil)
|
||||
return http.NewRequest(http.MethodGet, serverURL.String()+backend.Path, nil)
|
||||
}
|
||||
|
||||
// copy the url and add the port to the host
|
||||
|
@ -141,7 +141,7 @@ func (backend *BackendHealthCheck) newRequest(serverURL *url.URL) (*http.Request
|
|||
u.Host = net.JoinHostPort(u.Hostname(), strconv.Itoa(backend.Port))
|
||||
u.Path = u.Path + backend.Path
|
||||
|
||||
return http.NewRequest("GET", u.String(), nil)
|
||||
return http.NewRequest(http.MethodGet, u.String(), nil)
|
||||
}
|
||||
|
||||
func checkHealth(serverURL *url.URL, backend *BackendHealthCheck) bool {
|
||||
|
@ -159,5 +159,5 @@ func checkHealth(serverURL *url.URL, backend *BackendHealthCheck) bool {
|
|||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
return err == nil && resp.StatusCode == 200
|
||||
return err == nil && resp.StatusCode == http.StatusOK
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue