Initial MVP commit
This commit is contained in:
commit
7bcf16a1d4
24 changed files with 2781 additions and 0 deletions
config
32
config/config.go
Normal file
32
config/config.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Site struct {
|
||||
URL string
|
||||
APIKey string
|
||||
Hosts []string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
LogIdentifier string
|
||||
Sites []Site
|
||||
}
|
||||
|
||||
func FromFilePath(filePath string) (config Config, err error) {
|
||||
data, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return config, fmt.Errorf("failed to read config file path %s: %w", filePath, err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
return config, fmt.Errorf("failed to unmarshal JSON from file path %s: %w", filePath, err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue