mirror of
https://github.com/Bornholm/formidable.git
synced 2025-07-15 18:11:33 +02:00
feat: add null:// update handler
This commit is contained in:
34
internal/data/updater/null/updater_handler.go
Normal file
34
internal/data/updater/null/updater_handler.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user