Implement MVC

This commit is contained in:
Sung Won Cho 2021-01-03 17:51:57 +11:00
commit cd5d094c25
146 changed files with 13596 additions and 2328 deletions

View file

@ -28,7 +28,7 @@ import (
"time"
"github.com/dnote/dnote/pkg/server/database"
"github.com/dnote/dnote/pkg/server/handlers"
"github.com/dnote/dnote/pkg/server/middleware"
"github.com/dnote/dnote/pkg/server/operations"
"github.com/pkg/errors"
)
@ -52,12 +52,12 @@ type notePage struct {
}
func (a AppShell) newNotePage(r *http.Request, noteUUID string) (notePage, error) {
user, _, err := handlers.AuthWithSession(a.DB, r, nil)
user, _, err := middleware.AuthWithSession(a.DB, r)
if err != nil {
return notePage{}, errors.Wrap(err, "authenticating with session")
}
note, ok, err := operations.GetNote(a.DB, noteUUID, user)
note, ok, err := operations.GetNote(a.DB, noteUUID, &user)
if !ok {
return notePage{}, ErrNotFound