allow register mock
This commit is contained in:
@@ -54,7 +54,7 @@ func (c *TestController) HelloSession() {
|
||||
c.Ctx.WriteString("error")
|
||||
return
|
||||
}
|
||||
c.SetSession("name", "Tom")
|
||||
_ = c.SetSession("name", "Tom")
|
||||
c.Ctx.WriteString("set")
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ func (s *SessionProvider) SessionAll(ctx context.Context) int {
|
||||
|
||||
// SessionGC do nothing
|
||||
func (s *SessionProvider) SessionGC(ctx context.Context) {
|
||||
// we do anything since we don't need to mock GC
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +106,7 @@ func (s *SessionStore) SessionID(ctx context.Context) string {
|
||||
|
||||
// SessionRelease do nothing
|
||||
func (s *SessionStore) SessionRelease(ctx context.Context, w http.ResponseWriter) {
|
||||
// Support in the future if necessary, now I think we don't need to implement this
|
||||
}
|
||||
|
||||
func (s *SessionStore) Flush(ctx context.Context) error {
|
||||
|
||||
@@ -70,15 +70,11 @@ var provides = make(map[string]Provider)
|
||||
var SLogger = NewSessionLog(os.Stderr)
|
||||
|
||||
// Register makes a session provide available by the provided name.
|
||||
// If Register is called twice with the same name or if driver is nil,
|
||||
// it panics.
|
||||
// If provider is nil, it panic
|
||||
func Register(name string, provide Provider) {
|
||||
if provide == nil {
|
||||
panic("session: Register provide is nil")
|
||||
}
|
||||
if _, dup := provides[name]; dup {
|
||||
panic("session: Register called twice for provider " + name)
|
||||
}
|
||||
provides[name] = provide
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user