2020-08-10 08:18:04 -05:00
|
|
|
package config
|
|
|
|
|
|
|
|
type SyncAPI struct {
|
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2020-08-13 06:16:37 -05:00
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
2020-08-13 12:27:19 -05:00
|
|
|
ExternalAPI ExternalAPIOptions `yaml:"external_api"`
|
2020-08-10 08:18:04 -05:00
|
|
|
|
|
|
|
Database DatabaseOptions `yaml:"database"`
|
2020-11-20 05:29:02 -06:00
|
|
|
|
|
|
|
RealIPHeader string `yaml:"real_ip_header"`
|
2020-08-10 08:18:04 -05:00
|
|
|
}
|
|
|
|
|
2021-11-24 05:57:39 -06:00
|
|
|
func (c *SyncAPI) Defaults(generate bool) {
|
2020-08-13 06:16:37 -05:00
|
|
|
c.InternalAPI.Listen = "http://localhost:7773"
|
|
|
|
c.InternalAPI.Connect = "http://localhost:7773"
|
2020-08-13 12:27:19 -05:00
|
|
|
c.ExternalAPI.Listen = "http://localhost:8073"
|
2021-03-08 07:18:29 -06:00
|
|
|
c.Database.Defaults(10)
|
2021-11-24 05:57:39 -06:00
|
|
|
if generate {
|
|
|
|
c.Database.ConnectionString = "file:syncapi.db"
|
|
|
|
}
|
2020-08-10 08:18:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *SyncAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
2022-05-03 10:35:06 -05:00
|
|
|
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
|
|
|
checkNotEmpty(configErrs, "sync_api.database", string(c.Database.ConnectionString))
|
|
|
|
}
|
2022-05-13 02:33:55 -05:00
|
|
|
if isMonolith { // polylith required configs below
|
|
|
|
return
|
|
|
|
}
|
|
|
|
checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
|
|
|
|
checkURL(configErrs, "sync_api.internal_api.connect", string(c.InternalAPI.Connect))
|
|
|
|
checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
|
2020-08-10 08:18:04 -05:00
|
|
|
}
|