From bd06b6e688c63ea9eb05e187e18ce535286ca3d4 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sun, 18 Dec 2022 19:32:42 -0500 Subject: cleanup --- registry/registry.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'registry/registry.go') diff --git a/registry/registry.go b/registry/registry.go index 3f88966..442e591 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -20,9 +20,7 @@ func NewRegistry(cfg config.Config) *Registry { reg := Registry{cfg: cfg} reg.handlerMap = make(map[string]Handler) for _, v := range cfg.Handlers { - // TODO clean up - fqn := fmt.Sprintf("acct:%s@%s", v.Name, cfg.Domain) - reg.handlerMap[fqn] = Handler{handlerCfg: v} + reg.handlerMap[fqn(v.Name, cfg.Domain)] = Handler{handlerCfg: v} } return ® } @@ -46,6 +44,10 @@ func (r *Registry) WebfingerResource(fqn string) (*resources.WebfingerResource, return resources.RenderWebfingerResource(handler.handlerCfg.Name, r.cfg.Domain) } +func fqn(name, domain string) string { + return fmt.Sprintf("acct:%s@%s", name, domain) +} + func (r *Registry) findByFQN(fqn string) *Handler { handler, ok := r.handlerMap[fqn] if !ok { @@ -55,6 +57,5 @@ func (r *Registry) findByFQN(fqn string) *Handler { } func (r *Registry) findByName(name string) *Handler { - fqn := fmt.Sprintf("acct:%s@%s", name, r.cfg.Domain) - return r.findByFQN(fqn) + return r.findByFQN(fqn(name, r.cfg.Domain)) } -- cgit v1.2.3