-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from najeal/config-split
Config split
- Loading branch information
Showing
11 changed files
with
529 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
) | ||
|
||
// API configuration containing the base URL and query parameters | ||
type APIConfig struct { | ||
BaseURL string `mapstructure:"base-url" json:"base-url"` | ||
QueryParams map[string]string `mapstructure:"query-parameters" json:"query-parameters"` | ||
HTTPHeaders map[string]string `mapstructure:"http-headers" json:"http-headers"` | ||
} | ||
|
||
func (c *APIConfig) Validate() error { | ||
if _, err := url.ParseRequestURI(c.BaseURL); err != nil { | ||
return fmt.Errorf("invalid base URL: %w", err) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.