From 45c03a7a9b202bc125ec9e7bdab60cbfa0f6164f Mon Sep 17 00:00:00 2001 From: udhos Date: Thu, 28 Dec 2023 14:25:37 -0300 Subject: [PATCH] Add workspace-aware NewHTTPPoolWithWorkspace. --- http.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/http.go b/http.go index 127f684..e5f7439 100644 --- a/http.go +++ b/http.go @@ -76,14 +76,22 @@ type HTTPPoolOptions struct { Context func(*http.Request) context.Context } +// NewHTTPPoolWithWorkspace initializes an HTTP pool of peers, and registers itself as a PeerPicker. +// For convenience, it also registers itself as an http.Handler with http.DefaultServeMux. +// The self argument should be a valid base URL that points to the current server, +// for example "http://example.net:8000". +func NewHTTPPoolWithWorkspace(ws *workspace, self string) *HTTPPool { + p := NewHTTPPoolOptsWithWorkspace(ws, self, nil) + http.Handle(p.opts.BasePath, p) + return p +} + // NewHTTPPool initializes an HTTP pool of peers, and registers itself as a PeerPicker. // For convenience, it also registers itself as an http.Handler with http.DefaultServeMux. // The self argument should be a valid base URL that points to the current server, // for example "http://example.net:8000". func NewHTTPPool(self string) *HTTPPool { - p := NewHTTPPoolOpts(self, nil) - http.Handle(p.opts.BasePath, p) - return p + return NewHTTPPoolWithWorkspace(DefaultWorkspace, self) } // NewHTTPPoolOptsWithWorkspace initializes an HTTP pool of peers with the given options.