mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Expose a standard Session interface on context/context.go | https://github.com/kataras/iris/issues/316
This commit is contained in:
parent
5579153614
commit
3f13707428
12
context.go
12
context.go
|
@ -865,17 +865,7 @@ func (ctx *Context) SetFlash(key string, value string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session returns the current session
|
// Session returns the current session
|
||||||
func (ctx *Context) Session() interface {
|
func (ctx *Context) Session() context.Session {
|
||||||
ID() string
|
|
||||||
Get(string) interface{}
|
|
||||||
GetString(key string) string
|
|
||||||
GetInt(key string) int
|
|
||||||
GetAll() map[string]interface{}
|
|
||||||
VisitAll(cb func(k string, v interface{}))
|
|
||||||
Set(string, interface{})
|
|
||||||
Delete(string)
|
|
||||||
Clear()
|
|
||||||
} {
|
|
||||||
if ctx.framework.sessions == nil { // this should never return nil but FOR ANY CASE, on future changes.
|
if ctx.framework.sessions == nil { // this should never return nil but FOR ANY CASE, on future changes.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
// Session is the domain-level session's store interface
|
||||||
|
// it's synced with the iris/sessions.go:session
|
||||||
|
Session interface {
|
||||||
|
ID() string
|
||||||
|
Get(string) interface{}
|
||||||
|
GetString(key string) string
|
||||||
|
GetInt(key string) int
|
||||||
|
GetAll() map[string]interface{}
|
||||||
|
VisitAll(cb func(k string, v interface{}))
|
||||||
|
Set(string, interface{})
|
||||||
|
Delete(string)
|
||||||
|
Clear()
|
||||||
|
}
|
||||||
|
|
||||||
// IContext the interface for the iris/context
|
// IContext the interface for the iris/context
|
||||||
// Used mostly inside packages which shouldn't be import ,directly, the kataras/iris.
|
// Used mostly inside packages which shouldn't be import ,directly, the kataras/iris.
|
||||||
|
@ -71,17 +84,7 @@ type (
|
||||||
GetFlashes() map[string]string
|
GetFlashes() map[string]string
|
||||||
GetFlash(string) (string, error)
|
GetFlash(string) (string, error)
|
||||||
SetFlash(string, string)
|
SetFlash(string, string)
|
||||||
Session() interface {
|
Session() Session
|
||||||
ID() string
|
|
||||||
Get(string) interface{}
|
|
||||||
GetString(key string) string
|
|
||||||
GetInt(key string) int
|
|
||||||
GetAll() map[string]interface{}
|
|
||||||
VisitAll(cb func(k string, v interface{}))
|
|
||||||
Set(string, interface{})
|
|
||||||
Delete(string)
|
|
||||||
Clear()
|
|
||||||
}
|
|
||||||
SessionDestroy()
|
SessionDestroy()
|
||||||
Log(string, ...interface{})
|
Log(string, ...interface{})
|
||||||
Reset(*fasthttp.RequestCtx)
|
Reset(*fasthttp.RequestCtx)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user