sessions

package module
v0.0.0-...-6793ab1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2016 License: MIT Imports: 5 Imported by: 0

README

sessions

A sessions middleware that works well (but not exclusively) with rkusa/web.

Build Status GoDoc

Example

Use Middleware

app := app.New()
app.Use(sessions.Middleware("testsid", NewCookieStore([]byte("key"))))

Read session

sessions := sessions.FromContext(ctx)
fmt.Println(sessions["foo"])

License

MIT

Documentation

Overview

Package sessions provides a sessions middleware that works well (but not exclusively) with rkusa/web(https://github.com/rkusa/web).

app := app.New()
app.Use(sessions.Middleware("testsid", sessions.NewCookieStore([]byte("your-secret-key"))))

add this

Read session

sessions := sessions.FromContext(r.Context())
fmt.Println(sessions["foo"])

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) map[interface{}]interface{}

FromContext reads the session from the given context.

func Middleware

func Middleware(name string, store Store) func(http.ResponseWriter, *http.Request, http.HandlerFunc)

Middleware returns a middleware.

Types

type CookieStore

type CookieStore interface {
	Store
}

func NewCookieStore

func NewCookieStore(keyPairs ...[]byte) CookieStore

NewCookieStore creates a new CookieStore with the given key pairs.

type Store

type Store sessions.Store

Jump to

Keyboard shortcuts

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