feat(api): fix POST /invoice
This commit is contained in:
43
internal/config/config.go
Normal file
43
internal/config/config.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/internal/email"
|
||||
)
|
||||
|
||||
// PDF holds the configuration for the PDF generator.
|
||||
type PDF struct {
|
||||
Hostname string `json:"hostname"`
|
||||
}
|
||||
|
||||
// Gitea holds the configuration for the Gitea client.
|
||||
type Gitea struct {
|
||||
URL string `json:"url"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
// Config holds the configuration for the entire application.
|
||||
type Config struct {
|
||||
Email email.Config `json:"email"`
|
||||
PDF PDF `json:"pdf"`
|
||||
Gitea Gitea `json:"gitea"`
|
||||
}
|
||||
|
||||
// Load loads the configuration from a JSON file.
|
||||
func Load(path string) (*Config, error) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
cfg := &Config{}
|
||||
decoder := json.NewDecoder(file)
|
||||
if err := decoder.Decode(cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user