wdcli: Use progress writer instead of IOStream

This commit is contained in:
Tom Wiesing 2022-11-30 11:39:29 +01:00
parent 890022ae64
commit 3b78b06fff
No known key found for this signature in database
49 changed files with 396 additions and 393 deletions

View file

@ -2,24 +2,24 @@ package control
import (
"context"
"fmt"
"io"
"net/http"
"github.com/tkw1536/goprogram/stream"
)
// Server returns an http.Mux that implements the main server instance.
// The server may spawn background tasks, but these should be terminated once context closes.
//
// Logging messages are directed to io.
func (control *Control) Server(ctx context.Context, io stream.IOStream) (*http.ServeMux, error) {
// Logging messages are directed to progress
func (control *Control) Server(ctx context.Context, progress io.Writer) (*http.ServeMux, error) {
// create a new mux
mux := http.NewServeMux()
// add all the servable routes!
for _, s := range control.Servables {
for _, route := range s.Routes() {
io.Printf("mounting %s\n", route)
handler, err := s.Handler(ctx, route, io)
fmt.Fprintf(progress, "mounting %s\n", route)
handler, err := s.Handler(ctx, route, progress)
if err != nil {
return nil, err
}