mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
- Move lib/httputil.Transport to lib/promauth.NewTLSTransport. Remove the first arg to this function (URL),
since it has zero relation to the created transport.
- Move lib/httputil.TLSConfig to lib/promauth.NewTLSConfig. Re-use the existing functionality
from lib/promauth.Config for creating TLS config. This enables the following features:
- Ability to load key, cert and CA files from http urls.
- Ability to change the key, cert and CA files without the need to restart the service.
It automatically re-loads the new files after they change.
18 lines
330 B
Go
18 lines
330 B
Go
package httputil
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
// CheckURL checks whether urlStr contains valid URL.
|
|
func CheckURL(urlStr string) error {
|
|
if urlStr == "" {
|
|
return fmt.Errorf("url cannot be empty")
|
|
}
|
|
if _, err := url.Parse(urlStr); err != nil {
|
|
return fmt.Errorf("failed to parse url %q: %w", urlStr, err)
|
|
}
|
|
return nil
|
|
}
|