Skip to content

Commit

Permalink
Fix panic from not checking for nil (#19)
Browse files Browse the repository at this point in the history
* Fix panic from not checking for nil

* add fmt package
  • Loading branch information
jamesgoodhouse authored and vishr committed Dec 29, 2019
1 parent fb243c4 commit bf64792
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package session

import (
"fmt"

"github.com/gorilla/context"
"github.com/gorilla/sessions"
"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -32,7 +34,11 @@ var (

// Get returns a named session.
func Get(name string, c echo.Context) (*sessions.Session, error) {
store := c.Get(key).(sessions.Store)
s := c.Get(key)
if s == nil {
return nil, fmt.Errorf("%q session not found", name)
}
store := s.(sessions.Store)
return store.Get(c.Request(), name)
}

Expand Down

0 comments on commit bf64792

Please sign in to comment.