From 09c1c4caabe206fb825575b04f9de932da2aa785 Mon Sep 17 00:00:00 2001 From: nytpu Date: Wed, 17 Mar 2021 08:42:06 -0600 Subject: [PATCH] add general Update* in fetch.go TODO: implement backend protocol functions --- fetch/fetch.go | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/fetch/fetch.go b/fetch/fetch.go index 5c6809a..1f16143 100644 --- a/fetch/fetch.go +++ b/fetch/fetch.go @@ -42,13 +42,43 @@ func NewPage(remoteURL *url.URL, title string) (*core.Page, error) { } // UpdateFeed will check an existing core.Feed for updates -func UpdateFeed(feed *core.Feed) error { - // TODO +func UpdateFeed(f *core.Feed) error { + switch f.FeedLink.Scheme { + case "gemini": + // return updateGeminiFeed(f) + // TODO + fallthrough + case "http", "https": + // return updateHTTPFeed(f) + // TODO + fallthrough + case "gopher", "gophers": + // return updateGopherFeed(f) + // TODO + fallthrough + default: + return fmt.Errorf("Unsupported protocol '%s'", f.FeedLink.Scheme) + } return nil } // UpdatePage will check an existing core.Page for updages -func UpdatePage(page *core.Page) error { - // TODO +func UpdatePage(p *core.Page) error { + switch p.Link.Scheme { + case "gemini": + // return updateGeminiPage(p) + // TODO + fallthrough + case "http", "https": + // return updateHTTPPage(p) + // TODO + fallthrough + case "gopher", "gophers": + // return updateGopherPage(p) + // TODO + fallthrough + default: + return fmt.Errorf("Unsupported protocol '%s'", p.Link.Scheme) + } return nil }