-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_config.go
More file actions
46 lines (37 loc) · 782 Bytes
/
Copy pathapp_config.go
File metadata and controls
46 lines (37 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"errors"
"fmt"
"log"
"net/url"
)
type AppConfig struct {
IFTTTAPIKey string
IFTTTAPIURL string
SecretKey string
HTTPPort string
Namespace string
}
func (ac *AppConfig) ValidateIFTTTAPIKey() error {
if len(ac.IFTTTAPIKey) == 0 {
return errors.New("please specify an IFTTT API Key")
}
return nil
}
func (ac *AppConfig) ValidateIFTTTAPIURL() error {
if len(ac.IFTTTAPIURL) == 0 {
return errors.New("please specify an IFTTT API URL")
}
_, err := url.Parse(ac.IFTTTAPIURL)
if err != nil {
log.Print(err)
return fmt.Errorf("invalid IFTTT API URL: %s", ac.IFTTTAPIURL)
}
return nil
}
func (ac *AppConfig) ValidateHTTPPort() error {
if len(ac.HTTPPort) == 0 {
return errors.New("please specify HTTP Port")
}
return nil
}