diff --git a/internal/domain/accounts.go b/internal/domain/accounts.go new file mode 100644 index 000000000..4188b5afd --- /dev/null +++ b/internal/domain/accounts.go @@ -0,0 +1 @@ +package domain diff --git a/internal/domain/auth.go b/internal/domain/auth.go new file mode 100644 index 000000000..4188b5afd --- /dev/null +++ b/internal/domain/auth.go @@ -0,0 +1 @@ +package domain diff --git a/internal/domain/bookmarks.go b/internal/domain/bookmarks.go new file mode 100644 index 000000000..4188b5afd --- /dev/null +++ b/internal/domain/bookmarks.go @@ -0,0 +1 @@ +package domain diff --git a/internal/domain/tags.go b/internal/domain/tags.go new file mode 100644 index 000000000..021ae2335 --- /dev/null +++ b/internal/domain/tags.go @@ -0,0 +1,20 @@ +package domain + +import ( + "github.com/go-shiori/shiori/internal/database" + "github.com/go-shiori/shiori/internal/model" +) + +type TagsDomain struct { + db database.DB +} + +func (d TagsDomain) GetTags() ([]model.Tag, error) { + return d.db.GetTags() +} + +func NewTagsDomain(db database.DB) TagsDomain { + return TagsDomain{ + db: db, + } +} diff --git a/internal/webserver/handler-api.go b/internal/webserver/handler-api.go index c3e9620b9..48b81de1f 100644 --- a/internal/webserver/handler-api.go +++ b/internal/webserver/handler-api.go @@ -225,7 +225,7 @@ func (h *handler) apiGetTags(w http.ResponseWriter, r *http.Request, ps httprout checkError(err) // Fetch all tags - tags, err := h.DB.GetTags() + tags, err := h.tags.GetTags() checkError(err) w.Header().Set("Content-Type", "application/json") diff --git a/internal/webserver/handler.go b/internal/webserver/handler.go index 4be67a667..458bc4176 100644 --- a/internal/webserver/handler.go +++ b/internal/webserver/handler.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/go-shiori/shiori/internal/database" + "github.com/go-shiori/shiori/internal/domain" "github.com/go-shiori/shiori/internal/model" "github.com/go-shiori/warc" cch "github.com/patrickmn/go-cache" @@ -23,6 +24,8 @@ type handler struct { ArchiveCache *cch.Cache Log bool + tags domain.TagsDomain + templates map[string]*template.Template } diff --git a/internal/webserver/server.go b/internal/webserver/server.go index eb0fbb36c..ef6d5b91f 100644 --- a/internal/webserver/server.go +++ b/internal/webserver/server.go @@ -7,6 +7,7 @@ import ( "time" "github.com/go-shiori/shiori/internal/database" + "github.com/go-shiori/shiori/internal/domain" "github.com/julienschmidt/httprouter" cch "github.com/patrickmn/go-cache" "github.com/sirupsen/logrus" @@ -115,6 +116,8 @@ func ServeApp(cfg Config) error { ArchiveCache: cch.New(time.Minute, 5*time.Minute), RootPath: cfg.RootPath, Log: cfg.Log, + + tags: domain.NewTagsDomain(cfg.DB), } hdl.prepareSessionCache()