FedP2P/internal/testutil/status_writer.go

23 lines
357 B
Go
Raw Normal View History

package testutil
import (
"fmt"
"io"
"net/http"
"github.com/anacrolix/missinggo"
)
type StatusWriter interface {
WriteStatus(io.Writer)
}
func ExportStatusWriter(sw StatusWriter, path string) {
http.HandleFunc(
fmt.Sprintf("/%s/%s", missinggo.GetTestName(), path),
func(w http.ResponseWriter, r *http.Request) {
sw.WriteStatus(w)
},
)
}