feat: add null:// update handler

This commit is contained in:
2022-08-01 15:33:41 +02:00
committed by Bornholm
parent ab4f498b7c
commit bbdfb30205
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package null
import (
"io"
"net/url"
)
const SchemeNull = "null"
type UpdaterHandler struct{}
func (h *UpdaterHandler) Match(url *url.URL) bool {
return url.Scheme == SchemeNull
}
func (u *UpdaterHandler) Update(url *url.URL) (io.WriteCloser, error) {
return &nullCloser{}, nil
}
func NewUpdaterHandler() *UpdaterHandler {
return &UpdaterHandler{}
}
type nullCloser struct {
io.WriteCloser
}
func (c *nullCloser) Write(p []byte) (n int, err error) {
return io.Discard.Write(p)
}
func (c *nullCloser) Close() error {
return nil
}