Categorygithub.com/ddouglas/dynastore
modulepackage
0.3.0
Repository: https://github.com/ddouglas/dynastore.git
Documentation: pkg.go.dev

# README

dynastore

AWS DynamoDB store for Gorilla Toolkit using AWS library.

This is a fork and overhaul of the original repo which hadn't been updated in a long time. I was able to simplify it quite a bit with the v2 API and remove all the serialization code. It also no longer produces output when it encounters errors, it just returns them.

Uses the official AWS library, github.com/aws/aws-sdk-go-v2/aws

Installation

go get github.com/ddouglas/[email protected]

Environment Variables

dynastore uses the common AWS environment variables:

  • AWS_DEFAULT_REGION or AWS_REGION
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

dynastore will also use AWS roles if they are available. In that case, only AWS_DEFAULT_REGION or AWS_REGION need be set.

Alternately, AWS settings can be specified using Options:

  • dynastore.AWSConfig(*aws.Config)
  • dynastore.DynamoDB(*dynamodb.DynamoDB)

Example

// Create Store
store, err := dynastore.New("session", dynastore.Path("/"), dynastore.HTTPOnly())
if err != nil {
  log.Fatalln(err)
}

// Get Session
session, err := store.Get(req, "session-key")
if err != nil {
  log.Fatalln(err)
}

// Add a Value
session.Values["hello"] = "world"

// Save Session
err := session.Save(req, w)
if err != nil {
  log.Fatalln(err)
}

// Delete Session
session.Options.MaxAge = -1
err := session.Save(req, w)
if err != nil {
  log.Fatalln(err)
}

# Functions

Domain sets the default session option of the same name.
DynamoDB allows a pre-configured dynamodb client to be supplied.
HTTPOnly sets the default session option HttpOnly; HTTP is all capped to satisfy golint.
MaxAge sets the default session option of the same name.
New instantiates a new Store that implements gorilla's sessions.Store interface.
Path sets the default session option of the same name.
No description provided by the author
No description provided by the author
Secure sets the default session option of the same name.
SessionOptions allows the default session options to be specified in a single command.
TableName allows a custom table name to be specified.

# Constants

No description provided by the author
No description provided by the author
DefaultTTLField contains the default name of the ttl field.

# Structs

Store provides an implementation of the gorilla sessions.Store interface backed by DynamoDB.

# Type aliases

Option provides options to creating a dynastore.