1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 23:42:20 +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:
Juan Batiz-Benet
2015-07-31 17:34:56 -04:00
parent d50def3f5c
commit 3f1cbe2f43
9 changed files with 36 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package main
import (
_ "expvar"
"fmt"
"net"
"net/http"
_ "net/http/pprof"
"os"
@ -126,8 +127,8 @@ future version, along with this notice. Please move to setting the HTTP Headers.
// mostly useful to hook up things that register in the default muxer,
// and don't provide a convenient http.Handler entry point, such as
// expvar and http/pprof.
func defaultMux(path string) func(node *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
return func(node *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
func defaultMux(path string) corehttp.ServeOption {
return func(node *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.Handle(path, http.DefaultServeMux)
return mux, nil
}