formidable/internal/data/updater/stdout/updater_handler.go

36 lines
583 B
Go
Raw Normal View History

2022-05-10 22:31:17 +02:00
package stdout
import (
"io"
"net/url"
"os"
)
const SchemeStdout = "stdout"
type UpdaterHandler struct{}
func (h *UpdaterHandler) Match(url *url.URL) bool {
return url.Scheme == SchemeStdout
}
func (u *UpdaterHandler) Update(url *url.URL) (io.WriteCloser, error) {
2022-08-01 17:13:02 +02:00
return &stdoutFakeCloser{}, nil
2022-05-10 22:31:17 +02:00
}
func NewUpdaterHandler() *UpdaterHandler {
return &UpdaterHandler{}
}
2022-08-01 17:13:02 +02:00
type stdoutFakeCloser struct {
io.WriteCloser
}
func (c *stdoutFakeCloser) Write(p []byte) (n int, err error) {
return os.Stdout.Write(p)
}
func (c *stdoutFakeCloser) Close() error {
return nil
}