mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 17:22:21 +08:00
corehttp: add net.Listener to ServeOption
ServeOptions take the node and muxer, they should get the listener too as sometimes they need to operate on the listener address. License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
This commit is contained in:
@ -55,6 +55,14 @@ func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode {
|
||||
return n
|
||||
}
|
||||
|
||||
type delegatedHandler struct {
|
||||
http.Handler
|
||||
}
|
||||
|
||||
func (dh *delegatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
dh.Handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func TestGatewayGet(t *testing.T) {
|
||||
t.Skip("not sure whats going on here")
|
||||
ns := mockNamesys{}
|
||||
@ -65,7 +73,14 @@ func TestGatewayGet(t *testing.T) {
|
||||
}
|
||||
ns["example.com"] = path.FromString("/ipfs/" + k)
|
||||
|
||||
h, err := makeHandler(n,
|
||||
// need this variable here since we need to construct handler with
|
||||
// listener, and server with handler. yay cycles.
|
||||
dh := &delegatedHandler{}
|
||||
ts := httptest.NewServer(dh)
|
||||
defer ts.Close()
|
||||
|
||||
dh.Handler, err = makeHandler(n,
|
||||
ts.Listener,
|
||||
IPNSHostnameOption(),
|
||||
GatewayOption(false),
|
||||
)
|
||||
@ -73,9 +88,6 @@ func TestGatewayGet(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ts := httptest.NewServer(h)
|
||||
defer ts.Close()
|
||||
|
||||
t.Log(ts.URL)
|
||||
for _, test := range []struct {
|
||||
host string
|
||||
|
Reference in New Issue
Block a user