Skip to content

Commit

Permalink
revert to passing store around
Browse files Browse the repository at this point in the history
  • Loading branch information
seagyn committed May 26, 2022
1 parent 15886d6 commit 0aa245b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions inertia.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ type Inertia struct {
url string
rootTemplate string
version string
session *session.Session
store *session.Store
sharedProps map[string]interface{}
sharedFuncMap template.FuncMap
templateFS fs.FS
}

// New function.
func New(url, rootTemplate, version string, session *session.Session) *Inertia {
func New(url, rootTemplate, version string, store *session.Store) *Inertia {
i := new(Inertia)
i.url = url
i.rootTemplate = rootTemplate
i.version = version
i.session = session
i.store = store
i.sharedProps = make(map[string]interface{})
i.sharedFuncMap = template.FuncMap{"marshal": marshal}

return i
}

// NewWithFS function.
func NewWithFS(url, rootTemplate, version string, session *session.Session, templateFS fs.FS) *Inertia {
i := New(url, rootTemplate, version, session)
func NewWithFS(url, rootTemplate, version string, store *session.Store, templateFS fs.FS) *Inertia {
i := New(url, rootTemplate, version, store)
i.templateFS = templateFS

return i
Expand Down
8 changes: 5 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ func (i *Inertia) Middleware(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusConflict)
}

message := i.session.Get("message")
sess, _ := i.store.Get(c)

message := sess.Get("message")

if message != nil {
i.Share("message", i.session.Get("message"))
i.session.Delete("message")
i.Share("message", sess.Get("message"))
sess.Delete("message")
}

// Go to next middleware:
Expand Down

0 comments on commit 0aa245b

Please sign in to comment.