2020-08-10 14:18:04 +01:00
|
|
|
package config
|
|
|
|
|
|
|
|
type SyncAPI struct {
|
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2020-08-13 12:16:37 +01:00
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
2020-08-13 18:27:19 +01:00
|
|
|
ExternalAPI ExternalAPIOptions `yaml:"external_api"`
|
2020-08-10 14:18:04 +01:00
|
|
|
|
|
|
|
Database DatabaseOptions `yaml:"database"`
|
2020-11-20 11:29:02 +00:00
|
|
|
|
|
|
|
RealIPHeader string `yaml:"real_ip_header"`
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *SyncAPI) Defaults() {
|
2020-08-13 12:16:37 +01:00
|
|
|
c.InternalAPI.Listen = "http://localhost:7773"
|
|
|
|
c.InternalAPI.Connect = "http://localhost:7773"
|
2020-08-13 18:27:19 +01:00
|
|
|
c.ExternalAPI.Listen = "http://localhost:8073"
|
2020-08-10 14:18:04 +01:00
|
|
|
c.Database.Defaults()
|
|
|
|
c.Database.ConnectionString = "file:syncapi.db"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *SyncAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
2020-08-13 12:16:37 +01:00
|
|
|
checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
|
|
|
|
checkURL(configErrs, "sync_api.internal_api.bind", string(c.InternalAPI.Connect))
|
2020-08-13 18:27:19 +01:00
|
|
|
if !isMonolith {
|
|
|
|
checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
|
|
|
|
}
|
2020-08-10 14:18:04 +01:00
|
|
|
checkNotEmpty(configErrs, "sync_api.database", string(c.Database.ConnectionString))
|
|
|
|
}
|