summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
Diffstat (limited to 'svc')
-rw-r--r--svc/cache_test.go2
-rw-r--r--svc/db_test.go4
-rw-r--r--svc/init.go2
-rw-r--r--svc/init_test.go4
-rw-r--r--svc/post.go2
-rw-r--r--svc/post_test.go6
-rw-r--r--svc/query_test.go6
7 files changed, 13 insertions, 13 deletions
diff --git a/svc/cache_test.go b/svc/cache_test.go
index f167913..af2b1de 100644
--- a/svc/cache_test.go
+++ b/svc/cache_test.go
@@ -45,7 +45,7 @@ func Test_cacheUpdate(t *testing.T) {
 		t.Logf("both are in the expected order. I need to do some more investigation before I can correct the test")
 		t.Logf("or correct the library functions.")
 		t.SkipNow()
-		raw, _, _ := registry.GetTwtxt(urls)
+		raw, _, _ := registry.GetTwtxt(urls, nil)
 		manual, _ := registry.ParseUserTwtxt(raw, "gbmor", urls)
 
 		if !reflect.DeepEqual(newStatus, manual) {
diff --git a/svc/db_test.go b/svc/db_test.go
index 3c0abdf..7d3386c 100644
--- a/svc/db_test.go
+++ b/svc/db_test.go
@@ -11,7 +11,7 @@ func Test_pushpullDatabase(t *testing.T) {
 	initTestConf()
 	initTestDB()
 
-	out, _, err := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
+	out, _, err := registry.GetTwtxt("https://gbmor.dev/twtxt.txt", nil)
 	if err != nil {
 		t.Errorf("Couldn't set up test: %v\n", err)
 	}
@@ -55,7 +55,7 @@ func Benchmark_pushDatabase(b *testing.B) {
 	initTestDB()
 
 	if _, ok := twtxtCache.Users["https://gbmor.dev/twtxt.txt"]; !ok {
-		out, _, err := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
+		out, _, err := registry.GetTwtxt("https://gbmor.dev/twtxt.txt", nil)
 		if err != nil {
 			b.Errorf("Couldn't set up benchmark: %v\n", err)
 		}
diff --git a/svc/init.go b/svc/init.go
index b00f45d..3e7ab5e 100644
--- a/svc/init.go
+++ b/svc/init.go
@@ -42,7 +42,7 @@ var cTickC = make(chan *tick, 1)
 var tmpls *template.Template
 
 // Holds the registry data in-memory
-var twtxtCache = registry.NewIndex()
+var twtxtCache = registry.NewIndex(nil)
 
 // List of other registries submitted to this registry
 var remoteRegistries = &RemoteRegistries{
diff --git a/svc/init_test.go b/svc/init_test.go
index 314d5f4..72c8e3f 100644
--- a/svc/init_test.go
+++ b/svc/init_test.go
@@ -91,8 +91,8 @@ func testConfig() {
 // Creates a fresh mock registry, with a single
 // user and their statuses, for testing.
 func mockRegistry() {
-	twtxtCache = registry.NewIndex()
-	statuses, _, _ := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
+	twtxtCache = registry.NewIndex(nil)
+	statuses, _, _ := registry.GetTwtxt("https://gbmor.dev/twtxt.txt", nil)
 	parsed, _ := registry.ParseUserTwtxt(statuses, "gbmor", "https://gbmor.dev/twtxt.txt")
 	_ = twtxtCache.AddUser("gbmor", "https://gbmor.dev/twtxt.txt", "1", net.ParseIP("127.0.0.1"), parsed)
 }
diff --git a/svc/post.go b/svc/post.go
index 46032b9..9baafbe 100644
--- a/svc/post.go
+++ b/svc/post.go
@@ -28,7 +28,7 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) {
 
 	uip := getIPFromCtx(r.Context())
 
-	out, remoteRegistry, err := registry.GetTwtxt(urls)
+	out, remoteRegistry, err := registry.GetTwtxt(urls, twtxtCache.Client)
 	if err != nil {
 		errHTTP(w, r, fmt.Errorf("error fetching twtxt Data: %v", err.Error()), http.StatusBadRequest)
 		return
diff --git a/svc/post_test.go b/svc/post_test.go
index cee324c..1c7e9b5 100644
--- a/svc/post_test.go
+++ b/svc/post_test.go
@@ -46,7 +46,7 @@ var apiPostUserCases = []struct {
 func Test_apiPostUser(t *testing.T) {
 	initTestConf()
 	portnum := fmt.Sprintf(":%v", confObj.Port)
-	twtxtCache = registry.NewIndex()
+	twtxtCache = registry.NewIndex(nil)
 
 	for _, tt := range apiPostUserCases {
 		t.Run(tt.name, func(t *testing.T) {
@@ -78,7 +78,7 @@ func Test_apiPostUser(t *testing.T) {
 func Benchmark_apiPostUser(b *testing.B) {
 	initTestConf()
 	portnum := fmt.Sprintf(":%v", confObj.Port)
-	twtxtCache = registry.NewIndex()
+	twtxtCache = registry.NewIndex(nil)
 
 	params := url.Values{}
 	params.Set("url", "https://gbmor.dev/twtxt.txt")
@@ -91,7 +91,7 @@ func Benchmark_apiPostUser(b *testing.B) {
 		apiEndpointPOSTHandler(rr, req)
 
 		b.StopTimer()
-		twtxtCache = registry.NewIndex()
+		twtxtCache = registry.NewIndex(nil)
 		b.StartTimer()
 	}
 }
diff --git a/svc/query_test.go b/svc/query_test.go
index 687b102..414f99b 100644
--- a/svc/query_test.go
+++ b/svc/query_test.go
@@ -45,7 +45,7 @@ func Test_parseQueryOut(t *testing.T) {
 	urls := "https://gbmor.dev/twtxt.txt"
 	nick := "gbmor"
 
-	out, _, err := registry.GetTwtxt(urls)
+	out, _, err := registry.GetTwtxt(urls, nil)
 	if err != nil {
 		t.Errorf("Couldn't set up test: %v\n", err)
 	}
@@ -79,7 +79,7 @@ func Benchmark_parseQueryOut(b *testing.B) {
 	urls := "https://gbmor.dev/twtxt.txt"
 	nick := "gbmor"
 
-	out, _, err := registry.GetTwtxt(urls)
+	out, _, err := registry.GetTwtxt(urls, nil)
 	if err != nil {
 		b.Errorf("Couldn't set up test: %v\n", err)
 	}
@@ -184,7 +184,7 @@ func Test_compositeStatusQuery(t *testing.T) {
 
 func Benchmark_compositeStatusQuery(b *testing.B) {
 	initTestConf()
-	statuses, _, _ := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
+	statuses, _, _ := registry.GetTwtxt("https://gbmor.dev/twtxt.txt", nil)
 	parsed, _ := registry.ParseUserTwtxt(statuses, "gbmor", "https://gbmor.dev/twtxt.txt")
 	_ = twtxtCache.AddUser("gbmor", "https://gbmor.dev/twtxt.txt", "1", net.ParseIP("127.0.0.1"), parsed)
 	b.ResetTimer()