Skip to content

wolfeidau/dynamodbstore

Repository files navigation

dynamodbstore GoDoc

A session store backend for gorilla/sessions which uses AWS DynamoDB. It uses the official AWS Golang SDK.

Installation

go get -u github.com/wolfeidau/dynamodbstore

Usage

    // you may want to configure this centrally in your application
    sess := session.Must(session.NewSession())

    ddb := dynamodb.New(sess)

    // secret-key should be generated
    secretKey := "secret-key-should-be-in-config"
    
    store, err := dynamodbstore.NewDynamodbStore(ddb, []byte(secretKey))
	if err != nil {
		log.Fatal(err)
	}

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

    // Add a value.
    session.Values["foo"] = "bar"

    // Save.
    if err = sessions.Save(req, rsp); err != nil {
        log.Fatalf("Error saving session: %v", err)
    }

    // Delete session.
    session.Options.MaxAge = -1
    if err = sessions.Save(req, rsp); err != nil {
        log.Fatalf("Error saving session: %v", err)
    }

License

This code is released under MIT License, and is copyright Mark Wolfe.

About

A session store backend for gorilla/sessions which uses AWS DynamoDB.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published