Documentation ¶
Index ¶
- Constants
- type DynamoStore
- func (s *DynamoStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *DynamoStore) MaxAge(age int)
- func (s *DynamoStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *DynamoStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- type Session
Constants ¶
const ( // DefaultDynamoDBTableName is used when no table name is configured explicitly. DefaultDynamoDBTableName = "session-backend" // DefaultDynamoDBReadCapacity is the default read capacity that is used when none is configured explicitly. DefaultDynamoDBReadCapacity = 5 // DefaultDynamoDBWriteCapacity is the default write capacity that is used when none is configured explicitly. DefaultDynamoDBWriteCapacity = 5 // DefaultDynamoDBRegion is used when no region is configured explicitly. DefaultDynamoDBRegion = "us-east-1" // DefaultMaxAge is the default max age for session when none is configures explicitly. DefaultMaxAge = 86400 * 30 // DefaultTTLEnabled enables ttl by default for session object as recommended by AWS. DefaultTTLEnabled = true )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamoStore ¶
type DynamoStore struct { Codecs []securecookie.Codec Options *sessions.Options // default configuration // contains filtered or unexported fields }
DynamoStore stores sessions in dynamoDB.
func NewDynamoStore ¶
func NewDynamoStore(config map[string]interface{}, keyPairs ...[]byte) (*DynamoStore, error)
NewDynamoStore creates the dynamoDB store from given configuration config parameters expects the following keys:
1. table for dynamoDB table to store the session. (type: string)
2. read_capacity for read provisioned throughput for dynamoDB table. (type: int64)
3. write_capacity for write provisioned throughput for dynamoDB table. (type: int64)
4. region for aws region where the dynamoDB table will be created. (type: string)
5. endpoint for aws dynamoDB endpoint. (type: string)
6. max_age for maximum age of the session. (type: int64)
7. ttl_enabled for enabling ttl on the table. (type: bool)
If any of the keys is missing or wrong type is provided for the key, corresponding default value for the key will be used.
See https://github.com/gorilla/sessions/blob/master/store.go for detailed information on what keyPairs does.
func (*DynamoStore) Get ¶
Get returns a session for the given name after adding it to the registry.
It returns a new session if the sessions doesn't exist. Access IsNew on the session to check if it is an existing session or a new one.
It returns a new session and an error if the session exists but could not be decoded.
func (*DynamoStore) MaxAge ¶
func (s *DynamoStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.
func (*DynamoStore) New ¶
New returns a session for the given name without adding it to the registry.
The difference between New() and Get() is that calling New() twice will decode the session data twice, while Get() registers and reuses the same
func (*DynamoStore) Save ¶
func (s *DynamoStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
type Session ¶
type Session struct { // Identifier for session values ID string `json:"id"` // Encoded session values Data string `json:"data"` // Unix timestamp indicating when the session values were modified ModifiedAt int64 `json:"modified_at"` // TTL field for table TTL int64 `json:"ttl"` }
Session object stored in dynamoDB