Documentation ¶
Overview ¶
Copyright 2016 Wenhui Shen <www.webx.top> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Session implements middleware for easily using github.com/gorilla/sessions within echo. This package was originally inspired from the https://github.com/ipfans/echo-session package, and modified to provide more functionality
Index ¶
- func CloseBolt()
- func NewMySession(store Store, name string, ctx echo.Context) I.Session
- func NewSession(options *I.Options, setting interface{}, ctx echo.Context) I.Session
- type BoltStore
- type CookieStore
- type FilesystemStore
- type RedisStore
- type Session
- func (s *Session) AddFlash(value interface{}, vars ...string) I.Session
- func (s *Session) Clear() I.Session
- func (s *Session) Delete(key string) I.Session
- func (s *Session) Flashes(vars ...string) []interface{}
- func (s *Session) Get(key string) interface{}
- func (s *Session) Options(options I.Options) I.Session
- func (s *Session) Save() error
- func (s *Session) Session() *sessions.Session
- func (s *Session) Set(key string, val interface{}) I.Session
- func (s *Session) SetID(id string) I.Session
- func (s *Session) Written() bool
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CookieStore ¶
type CookieStore interface { Store }
func NewCookieStore ¶
func NewCookieStore(keyPairs ...[]byte) CookieStore
Keys are defined in pairs to allow key rotation, but the common case is to set a single authentication key and optionally an encryption key.
The first key in a pair is used for authentication and the second for encryption. The encryption key can be set to nil or omitted in the last pair, but the authentication key is required in all pairs.
It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
type FilesystemStore ¶
type FilesystemStore interface { Store }
func NewFilesystemStore ¶
func NewFilesystemStore(path string, keyPairs ...[]byte) FilesystemStore
NewFilesystemStore returns a new FilesystemStore.
The path argument is the directory where sessions will be saved. If empty it will use os.TempDir().
See NewCookieStore() for a description of the other parameters.
type RedisStore ¶
type RedisStore interface { Store }
func NewRedisStore ¶
func NewRedisStore(size int, network, address, password string, keyPairs ...[]byte) (RedisStore, error)
size: maximum number of idle connections. network: tcp or udp address: host:port password: redis-password Keys are defined in pairs to allow key rotation, but the common case is to set a single authentication key and optionally an encryption key.
The first key in a pair is used for authentication and the second for encryption. The encryption key can be set to nil or omitted in the last pair, but the authentication key is required in all pairs.
It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.