Add logging config and add some helper functions

This commit is contained in:
Gary Kramlich
2021-11-20 04:58:59 -06:00
parent e27846c25b
commit 8086ad1708
5 changed files with 125 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
package config
import (
as "maunium.net/go/mautrix/appservice"
)
type appservice struct {
Address string `yaml:"address"`
Hostname string `yaml:"hostname"`
@@ -49,3 +53,16 @@ func (a *appservice) UnmarshalYAML(unmarshal func(interface{}) error) error {
return a.validate()
}
func (cfg *Config) CreateAppService() (*as.AppService, error) {
appservice := as.Create()
appservice.HomeserverURL = cfg.Homeserver.Address
appservice.HomeserverDomain = cfg.Homeserver.Domain
appservice.Host.Hostname = cfg.Appservice.Hostname
appservice.Host.Port = cfg.Appservice.Port
appservice.DefaultHTTPRetries = 4
return appservice, nil
}