aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-12-19 00:32:42 +0000
committerJulio Capote <jcapote@gmail.com>2022-12-19 00:32:42 +0000
commitbd06b6e688c63ea9eb05e187e18ce535286ca3d4 (patch)
tree92954f44051865193a009af09e6f10a5fd83e697
parent2ee94a66d89de9eb0461f250251af7776aef9976 (diff)
downloadcommunique-bd06b6e688c63ea9eb05e187e18ce535286ca3d4.tar.gz
cleanup
-rw-r--r--registry/registry.go11
1 files changed, 6 insertions, 5 deletions
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 &reg
}
@@ -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))
}