mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-16 01:43:13 +00:00
- Moved readers to the config package - Added an option to read remote config files - Moved the validation package to the config package and removed the validator dependency - Moved the customerrors package to the config package - Replaced fatih/color with jedib0t/go-pretty/v6/text - Removed proxy check functionality - Added param, header, cookie, body, and proxy flags to the CLI - Allowed multiple values for the same key in params, headers, and cookies
45 lines
767 B
Go
45 lines
767 B
Go
package types
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"net/url"
|
|
)
|
|
|
|
type RequestURL struct {
|
|
url.URL
|
|
}
|
|
|
|
func (requestURL *RequestURL) UnmarshalJSON(data []byte) error {
|
|
var urlStr string
|
|
if err := json.Unmarshal(data, &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())
|
|
}
|
|
|
|
func (requestURL RequestURL) String() string {
|
|
return requestURL.URL.String()
|
|
}
|
|
|
|
func (requestURL *RequestURL) Set(value string) error {
|
|
parsedURL, err := url.Parse(value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
requestURL.URL = *parsedURL
|
|
return nil
|
|
}
|