used json's omitempty on structs to tidy output
This commit is contained in:
parent
3bdc960285
commit
cd590f7a05
3 changed files with 31 additions and 27 deletions
|
@ -108,7 +108,11 @@ func removeDisabledItems(cfg *Config) {
|
|||
cfg.OtherServices = new_svcs
|
||||
}
|
||||
|
||||
|
||||
func JSONifyConfig(content Config) string {
|
||||
data, err := json.Marshal(content)
|
||||
logger.CheckError(err)
|
||||
return string(data)
|
||||
}
|
||||
func JSONify(content interface{}) string {
|
||||
data, err := json.Marshal(content)
|
||||
logger.CheckError(err)
|
||||
|
|
|
@ -18,41 +18,41 @@ type Config struct {
|
|||
BaseURL string `yaml:"BaseURL"`
|
||||
Domains []string `yaml:"Domains"`
|
||||
LocalDomain string `yaml:"LocalDomain"`
|
||||
InMail Service `yaml:"InMail"`
|
||||
OutMail Service `yaml:"OutMail"`
|
||||
Calendar Service `yaml:"Calendar"`
|
||||
AddressBook Service `yaml:"AddressBook"`
|
||||
WebMail Service `yaml:"WebMail"`
|
||||
OtherServices []Service `yaml:"OtherServices"`
|
||||
InMail Service `yaml:"InMail" json:",omitempty"`
|
||||
OutMail Service `yaml:"OutMail" json:",omitempty"`
|
||||
Calendar Service `yaml:"Calendar" json:",omitempty"`
|
||||
AddressBook Service `yaml:"AddressBook" json:",omitempty"`
|
||||
WebMail Service `yaml:"WebMail" json:",omitempty"`
|
||||
OtherServices []Service `yaml:"OtherServices" json:",omitempty"`
|
||||
|
||||
}
|
||||
type Service struct {
|
||||
Name string `yaml:"Name"`
|
||||
Enabled bool `yaml:"Enabled"`
|
||||
Type string `yaml:"Type"`
|
||||
Server string `yaml:"Server"`
|
||||
Port int `yaml:"Port"`
|
||||
SocketType string `yaml:"SocketType"`
|
||||
SPA bool `yaml:"SPA"`
|
||||
UsernameIsFQDN bool `yaml:"UsernameIsFQDN"`
|
||||
RequireLocalDomain bool `yaml:"RequireLocalDomain"`
|
||||
NoAuthRequired bool `yaml:"NoAuthRequired"`
|
||||
Authentication string `yaml:"Authentication"`
|
||||
Name string `yaml:"Name" json:",omitempty"`
|
||||
Enabled bool `yaml:"Enabled" json:",omitempty"`
|
||||
Type string `yaml:"Type" json:",omitempty"`
|
||||
Server string `yaml:"Server" json:",omitempty"`
|
||||
Port int `yaml:"Port" json:",omitempty"`
|
||||
SocketType string `yaml:"SocketType" json:",omitempty"`
|
||||
SPA bool `yaml:"SPA" json:",omitempty"`
|
||||
UsernameIsFQDN bool `yaml:"UsernameIsFQDN" json:",omitempty"`
|
||||
RequireLocalDomain bool `yaml:"RequireLocalDomain" json:",omitempty"`
|
||||
NoAuthRequired bool `yaml:"NoAuthRequired" json:",omitempty"`
|
||||
Authentication string `yaml:"Authentication" json:",omitempty"`
|
||||
// For Outgoing Mail
|
||||
POPAuth bool `yaml:"POPAuth"`
|
||||
SMTPLast bool `yaml:"SMTPLast"`
|
||||
POPAuth bool `yaml:"POPAuth" json:",omitempty"`
|
||||
SMTPLast bool `yaml:"SMTPLast" json:",omitempty"`
|
||||
// For WebMail (Unused)
|
||||
UsernameDivID string `yaml:"UsernameDivID"`
|
||||
UsernameDivName string `yaml:"UsernameDivName"`
|
||||
PasswordDivName string `yaml:"PasswordDivName"`
|
||||
SubmitButtonID string `yaml:"SubmitButtonID"`
|
||||
SubmitButtonName string `yaml:"SubmitButtonName"`
|
||||
UsernameDivID string `yaml:"UsernameDivID" json:",omitempty"`
|
||||
UsernameDivName string `yaml:"UsernameDivName" json:",omitempty"`
|
||||
PasswordDivName string `yaml:"PasswordDivName" json:",omitempty"`
|
||||
SubmitButtonID string `yaml:"SubmitButtonID" json:",omitempty"`
|
||||
SubmitButtonName string `yaml:"SubmitButtonName" json:",omitempty"`
|
||||
}
|
||||
type Response struct {
|
||||
Url string `json:"url"`
|
||||
ContentType string `json:"content_type"`
|
||||
Message string `json:"message"`
|
||||
Content map[string]interface{} `json:"content"`
|
||||
Content map[string]interface{} `json:"content,omitempty"`
|
||||
Config Config `json:"_"`
|
||||
Email string `json:"_"`
|
||||
}
|
||||
|
|
|
@ -110,6 +110,6 @@ func DefaultResponse() string {
|
|||
}
|
||||
func OurConfig() string {
|
||||
global.ThisSession.ContentType = "application/json"
|
||||
content := global.JSONify(global.MainConfig)
|
||||
content := global.JSONifyConfig(global.MainConfig)
|
||||
return content
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue