backends: pass error logger to backends

This commit is contained in:
Michael Eischer committed 2025-10-03 18:22:42 +02:00
1 parent 13f743e26b
commit 4dc71f24c5
31 files changed
+96 -96

No files matched your search

+3 -3
View File
@@ -55,7 +55,7 @@ const (
)
// Open opens the REST backend with the given config.
func Open(_ context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) {
func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (*Backend, error) {
// use url without trailing slash for layout
url := cfg.URL.String()
if url[len(url)-1] == '/' {
@@ -84,8 +84,8 @@ func drainAndClose(resp *http.Response) error {
}
// Create creates a new REST on server configured in config.
func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) {
be, err := Open(ctx, cfg, rt)
func Create(ctx context.Context, cfg Config, rt http.RoundTripper, errorLog func(string, ...interface{})) (*Backend, error) {
be, err := Open(ctx, cfg, rt, errorLog)
if err != nil {
return nil, err
}
+1 -1
View File
@@ -117,7 +117,7 @@ func TestListAPI(t *testing.T) {
URL: srvURL,
}
be, err := rest.Open(context.TODO(), cfg, http.DefaultTransport)
be, err := rest.Open(context.TODO(), cfg, http.DefaultTransport, t.Logf)
if err != nil {
t.Fatal(err)
}
+1 -1
View File
@@ -106,7 +106,7 @@ func runRESTServer(ctx context.Context, t testing.TB, dir, reqListenAddr string)
matched = true
}
}
_, _ = fmt.Fprintln(os.Stdout, line) // print all output to console
t.Log(line)
}
}()