change logic location

This commit is contained in:
Adit Sachde 2019-10-01 12:38:05 -04:00
parent 619ece0c5c
commit 98aff17b12
10 changed files with 27 additions and 46 deletions

View file

@ -35,9 +35,6 @@ func main() {
base, accountDB, deviceDB, federation, alias, query, cache, base, accountDB, deviceDB, federation, alias, query, cache,
) )
if base.Cfg.Bind.AppServiceAPI != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.AppServiceAPI), string(base.Cfg.Listen.AppServiceAPI))
base.SetupAndServeHTTP(string(base.Cfg.Bind.AppServiceAPI))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.AppServiceAPI))
}
} }

View file

@ -44,9 +44,6 @@ func main() {
alias, input, query, typingInputAPI, asQuery, transactions.New(), alias, input, query, typingInputAPI, asQuery, transactions.New(),
) )
if base.Cfg.Bind.ClientAPI != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.ClientAPI), string(base.Cfg.Listen.ClientAPI))
base.SetupAndServeHTTP(string(base.Cfg.Bind.ClientAPI))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.ClientAPI))
}
} }

View file

@ -39,9 +39,6 @@ func main() {
alias, input, query, asQuery, alias, input, query, asQuery,
) )
if base.Cfg.Bind.FederationAPI != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationAPI), string(base.Cfg.Listen.FederationAPI))
base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationAPI))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.FederationAPI))
}
} }

View file

@ -32,9 +32,6 @@ func main() {
base, federation, query, base, federation, query,
) )
if base.Cfg.Bind.FederationSender != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationSender), string(base.Cfg.Listen.FederationSender))
base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationSender))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.FederationSender))
}
} }

View file

@ -28,9 +28,6 @@ func main() {
mediaapi.SetupMediaAPIComponent(base, deviceDB) mediaapi.SetupMediaAPIComponent(base, deviceDB)
if base.Cfg.Bind.MediaAPI != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.MediaAPI), string(base.Cfg.Listen.MediaAPI))
base.SetupAndServeHTTP(string(base.Cfg.Bind.MediaAPI))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.MediaAPI))
}
} }

View file

@ -28,9 +28,6 @@ func main() {
publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB) publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB)
if base.Cfg.Bind.PublicRoomsAPI != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.PublicRoomsAPI), string(base.Cfg.Listen.PublicRoomsAPI))
base.SetupAndServeHTTP(string(base.Cfg.Bind.PublicRoomsAPI))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.PublicRoomsAPI))
}
} }

View file

@ -28,9 +28,6 @@ func main() {
roomserver.SetupRoomServerComponent(base) roomserver.SetupRoomServerComponent(base)
if base.Cfg.Bind.RoomServer != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.RoomServer), string(base.Cfg.Listen.RoomServer))
base.SetupAndServeHTTP(string(base.Cfg.Bind.RoomServer))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.RoomServer))
}
} }

View file

@ -31,9 +31,6 @@ func main() {
syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, query) syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, query)
if base.Cfg.Bind.SyncAPI != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.SyncAPI), string(base.Cfg.Listen.SyncAPI))
base.SetupAndServeHTTP(string(base.Cfg.Bind.SyncAPI))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.SyncAPI))
}
} }

View file

@ -32,9 +32,6 @@ func main() {
typingserver.SetupTypingServerComponent(base, cache.NewTypingCache()) typingserver.SetupTypingServerComponent(base, cache.NewTypingCache())
if base.Cfg.Bind.TypingServer != "" { base.SetupAndServeHTTP(string(base.Cfg.Bind.TypingServer), string(base.Cfg.Listen.TypingServer))
base.SetupAndServeHTTP(string(base.Cfg.Bind.TypingServer))
} else {
base.SetupAndServeHTTP(string(base.Cfg.Listen.TypingServer))
}
} }

View file

@ -150,7 +150,15 @@ func (b *BaseDendrite) CreateFederationClient() *gomatrixserverlib.FederationCli
// SetupAndServeHTTP sets up the HTTP server to serve endpoints registered on // SetupAndServeHTTP sets up the HTTP server to serve endpoints registered on
// ApiMux under /api/ and adds a prometheus handler under /metrics. // ApiMux under /api/ and adds a prometheus handler under /metrics.
func (b *BaseDendrite) SetupAndServeHTTP(addr string) { func (b *BaseDendrite) SetupAndServeHTTP(bindaddr string, listenaddr string) {
var addr string
if bindaddr != "" {
addr = bindaddr
} else {
addr = listenaddr
}
common.SetupHTTPAPI(http.DefaultServeMux, common.WrapHandlerInCORS(b.APIMux)) common.SetupHTTPAPI(http.DefaultServeMux, common.WrapHandlerInCORS(b.APIMux))
logrus.Infof("Starting %s server on %s", b.componentName, addr) logrus.Infof("Starting %s server on %s", b.componentName, addr)