dnscontrol/pkg/cloudflare-go/utils.go
Tom Limoncelli 7fd6a74e0c
CLOUDFLAREAPI: CF_REDIRECT/CF_TEMP_REDIRECT should dtrt using Single Redirects (#3002)
Co-authored-by: Josh Zhang <jzhang1@stackoverflow.com>
2024-06-18 17:38:50 -04:00

28 lines
662 B
Go

package cloudflare
import (
"fmt"
"net/url"
"os"
"path/filepath"
"github.com/google/go-querystring/query"
)
// buildURI assembles the base path and queries.
func buildURI(path string, options interface{}) string {
v, _ := query.Values(options)
return (&url.URL{Path: path, RawQuery: v.Encode()}).String()
}
// loadFixture takes a series of path components and returns the JSON fixture at
// that location associated.
func loadFixture(parts ...string) string {
paths := []string{"testdata", "fixtures"}
paths = append(paths, parts...)
b, err := os.ReadFile(filepath.Join(paths...) + ".json")
if err != nil {
fmt.Print(err)
}
return string(b)
}