Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: logic domains #467

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/domain/accounts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package domain
1 change: 1 addition & 0 deletions internal/domain/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package domain
1 change: 1 addition & 0 deletions internal/domain/bookmarks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package domain
20 changes: 20 additions & 0 deletions internal/domain/tags.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
2 changes: 1 addition & 1 deletion internal/webserver/handler-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions internal/webserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,6 +24,8 @@ type handler struct {
ArchiveCache *cch.Cache
Log bool

tags domain.TagsDomain

templates map[string]*template.Template
}

Expand Down
3 changes: 3 additions & 0 deletions internal/webserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down