From fb6453db1d87df942a46db7267b590a2c35cf809 Mon Sep 17 00:00:00 2001 From: meows Date: Wed, 18 Dec 2019 09:01:58 -0600 Subject: [PATCH] rpc: refactor for concision Signed-off-by: meows --- rpc/endpoints.go | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/rpc/endpoints.go b/rpc/endpoints.go index dae5e0099b..f7813e60de 100644 --- a/rpc/endpoints.go +++ b/rpc/endpoints.go @@ -28,29 +28,25 @@ import ( // then log.Crit is used to cause program to exit, logging the invalid module and a list of available // API service names. func mustAvailableModule(module string, apis []API) { - apiExists := false for _, api := range apis { if module == api.Namespace { - apiExists = true - break + return } } - if !apiExists { - log.Crit("invalid api module", "module", module, "available", func() string { - available := []string{} - outer: - for _, api := range apis { - // Only include unique api names - for _, av := range available { - if av == api.Namespace { - continue outer - } + log.Crit("invalid api module", "module", module, "available", func() string { + available := []string{} + outer: + for _, api := range apis { + // Only include unique api names + for _, av := range available { + if av == api.Namespace { + continue outer } - available = append(available, api.Namespace) } - return strings.Join(available, ",") - }()) - } + available = append(available, api.Namespace) + } + return strings.Join(available, ",") + }()) } // StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules