📦 Add Storage interface

pull/964/head
Tom 2020-10-26 00:10:35 +00:00
parent f9fac80492
commit 4868e4dd50
No known key found for this signature in database
GPG Key ID: D3E7EAA31B39637E
1 changed files with 13 additions and 0 deletions

13
app.go
View File

@ -36,6 +36,19 @@ const Version = "2.1.1"
// Map is a shortcut for map[string]interface{}, useful for JSON returns
type Map map[string]interface{}
// Storage interface that is implemented by storage providers for different
// middleware packages like cache, limiter, session and csrf
type Storage interface {
// Get session value. If the ID is not found, it will return an empty []byte
Get(id string) ([]byte, error)
// Set session value. `exp` will be zero for no expiration.
Set(id string, value []byte, exp time.Duration) error
// Delete session value
Delete(id string) error
// Clear clears the storage
Clear() error
}
// Handler defines a function to serve HTTP requests.
type Handler = func(*Ctx) error