faunastore

package module
v0.0.0-...-4e091dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 11 Imported by: 0

README

Fauna Store

A Gorilla sessions store implemention backed by FaunaDB.

Example

client := f.NewFaunaClient(os.Getenv("FAUNA_PASS"))
store, err := NewFaunaStore(client)

Assumptions

This library assumes the existence of a sessions collection in the database to which it connects.

The tests assume you have an environment variable FAUNA_PASS defined with the connection info for FaunaDB.
If running the tests, be aware that they don't cleanup generated database records.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FaunaSession

type FaunaSession struct {
	Id  string `fauna:"id"`
	Val []byte `fauna:"val"`
}

type FaunaStore

type FaunaStore struct {
	// contains filtered or unexported fields
}

func NewFaunaStore

func NewFaunaStore(client *f.FaunaClient) (*FaunaStore, error)

func (*FaunaStore) Get

func (s *FaunaStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get should return a cached session.

func (*FaunaStore) New

func (s *FaunaStore) New(r *http.Request, name string) (*sessions.Session, error)

New should create and return a new session.

Note that New should never return a nil session, even in the case of an error if using the Registry infrastructure to cache the session.

func (*FaunaStore) Options

func (s *FaunaStore) Options(opts sessions.Options)

func (*FaunaStore) Save

func (s *FaunaStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error

Save should persist session to the underlying store implementation.

type GobSerializer

type GobSerializer struct{}

func (GobSerializer) Deserialize

func (gs GobSerializer) Deserialize(d []byte, s *sessions.Session) error

func (GobSerializer) Serialize

func (gs GobSerializer) Serialize(s *sessions.Session) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL