rpc: refactor for concision

Signed-off-by: meows <b5c6@protonmail.com>
This commit is contained in:
meows 2019-12-18 09:01:58 -06:00
parent ddaee90378
commit fb6453db1d
No known key found for this signature in database
GPG key ID: 5786AEA5C8D5A520

View file

@ -28,14 +28,11 @@ import (
// then log.Crit is used to cause program to exit, logging the invalid module and a list of available // then log.Crit is used to cause program to exit, logging the invalid module and a list of available
// API service names. // API service names.
func mustAvailableModule(module string, apis []API) { func mustAvailableModule(module string, apis []API) {
apiExists := false
for _, api := range apis { for _, api := range apis {
if module == api.Namespace { if module == api.Namespace {
apiExists = true return
break
} }
} }
if !apiExists {
log.Crit("invalid api module", "module", module, "available", func() string { log.Crit("invalid api module", "module", module, "available", func() string {
available := []string{} available := []string{}
outer: outer:
@ -51,7 +48,6 @@ func mustAvailableModule(module string, apis []API) {
return strings.Join(available, ",") return strings.Join(available, ",")
}()) }())
} }
}
// StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules // StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules
func StartHTTPEndpoint(endpoint string, apis []API, modules []string, cors []string, vhosts []string, timeouts HTTPTimeouts) (net.Listener, *Server, error) { func StartHTTPEndpoint(endpoint string, apis []API, modules []string, cors []string, vhosts []string, timeouts HTTPTimeouts) (net.Listener, *Server, error) {