Files
VictoriaMetrics/lib/httputil/url.go
Aliaksandr Valialkin 2f86ef95a1 lib/{httputil,promauth}: move functions, which create TLS config and TLS-based HTTP transport, from lib/httputil to lib/promauth
- 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.
2025-03-26 20:14:17 +01:00

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
}