Add yaml file reader to config

This commit is contained in:
2025-03-20 03:52:25 +04:00
parent 3cd72855e5
commit 459f7ee0dc
12 changed files with 293 additions and 95 deletions

View File

@@ -25,6 +25,21 @@ func (requestURL *RequestURL) UnmarshalJSON(data []byte) error {
return nil
}
func (requestURL *RequestURL) UnmarshalYAML(unmarshal func(interface{}) error) error {
var urlStr string
if err := unmarshal(&urlStr); err != nil {
return err
}
parsedURL, err := url.Parse(urlStr)
if err != nil {
return errors.New("Request URL is invalid")
}
requestURL.URL = *parsedURL
return nil
}
func (requestURL RequestURL) MarshalJSON() ([]byte, error) {
return json.Marshal(requestURL.URL.String())
}