Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                

cassandrastore

package module
v0.0.0-...-d4f5b68 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: MIT Imports: 9 Imported by: 0

README

cassandrastore

Gorilla's Session Store Implementation for Cassandra

Installation

Run go get github.com/nebulr/cassandrastore from command line. Gets installed in $GOPATH

Usage

NewCassandraStore takes the following paramaters

hosts - an array of ip address strings
keyspace - keyspace where <tableName> store is created
tableName - table where sessions are to be saved. Required fields are created automatically if the table doesnot exist.
path - path for Set-Cookie header
maxAge 
codecs

Internally, cassadrastore uses this Cassandra driver.

e.g.,

  package main

  import (
    "fmt"
    "github.com/nebulr/cassandrastore"
    "net/http"
  )

  var store *cassandrastore.CassandraStore

  func sessTest(w http.ResponseWriter, r *http.Request) {
    session, err := store.Get(r, "foobar")
    session.Values["bar"] = "baz"
    session.Values["baz"] = "foo"
    err = session.Save(r, w)
    fmt.Printf("%#v\n", session)
    fmt.Println(err)
  }

func main() {
    store, err := cassandrastore.NewCassandraStore([]string{"127.0.0.1"}, <keyspace>, <tablename>, "/", 3600, []byte("<SecretKey>"))
    if err != nil {
      panic(err)
    }
    defer store.Close()

	http.HandleFunc("/", sessTest)
	http.ListenAndServe(":8080", nil)
}

Credit to @srinathgs for his initial work on this MysqlStore

Documentation

Overview

Gorilla Sessions backend for Cassandra.

Copyright (c) 2018 Contributors. See the list of contributors in the CONTRIBUTORS file for details.

This software is licensed under a MIT style license available in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CassandraStore

type CassandraStore struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options
	// contains filtered or unexported fields
}

func NewCassandraStore

func NewCassandraStore(hosts []string, keyspace string, tableName string, path string, maxAge int, keyPairs ...[]byte) (*CassandraStore, error)

func NewCassandraStoreFromConnection

func NewCassandraStoreFromConnection(db *gocql.Session, tableName string, path string, maxAge int, keyPairs ...[]byte) (*CassandraStore, error)

func (*CassandraStore) Close

func (m *CassandraStore) Close()

func (*CassandraStore) Delete

func (m *CassandraStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error

func (*CassandraStore) Get

func (m *CassandraStore) Get(r *http.Request, name string) (*sessions.Session, error)

func (*CassandraStore) New

func (m *CassandraStore) New(r *http.Request, name string) (*sessions.Session, error)

func (*CassandraStore) Save

Jump to

Keyboard shortcuts

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