summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorBen Busby <contact@benbusby.com>2025-01-27 12:17:20 -0700
committerBen Busby <contact@benbusby.com>2025-01-27 12:17:20 -0700
commit6e64a93fd17767bfdb40dda94d354c7e57202ab1 (patch)
tree73a2990fe562085a781d6a88d568c129e169574e /db
parent3d52cddc669f580b74c66402d1e5cdcbbcfacb9d (diff)
downloadfarside-6e64a93fd17767bfdb40dda94d354c7e57202ab1.tar.gz
Update breezewiki routing behavior, update readme
BreezeWiki requires the subdomain of a fandom link to be preserved when routing, otherwise the redirect doesn't work correctly. Cleaned up readme examples
Diffstat (limited to 'db')
-rw-r--r--db/db.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/db/db.go b/db/db.go
index efdf145..17d1ba3 100644
--- a/db/db.go
+++ b/db/db.go
@@ -3,10 +3,12 @@ package db
import (
"encoding/json"
"errors"
+ "fmt"
"log"
"math/rand"
"os"
"slices"
+ "strings"
"time"
"github.com/benbusby/farside/services"
@@ -55,7 +57,7 @@ func SetInstances(service string, instances []string) error {
return nil
}
-func GetInstance(service string) (string, error) {
+func GetInstance(service, path string) (string, error) {
instances, err := GetAllInstances(service)
if err != nil || len(instances) == 0 {
if err != nil {
@@ -80,6 +82,12 @@ func GetInstance(service string) (string, error) {
index := rand.Intn(len(instances))
value := instances[index]
selectionMap[service] = value
+
+ if len(path) > 0 {
+ value = strings.TrimSuffix(value, "/")
+ value = fmt.Sprintf("%s/%s", value, path)
+ }
+
return value, nil
}