mirror of
https://github.com/aykhans/dodo.git
synced 2025-07-02 00:16:20 +00:00
🔨 Restructure entire project logic
- 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
This commit is contained in:
44
types/request_url.go
Normal file
44
types/request_url.go
Normal file
@ -0,0 +1,44 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user