qsess

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package qsess contains QRA integration with gorilla sessions cookie store.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidSessionName error.
	ErrInvalidSessionName = errors.New("session name must be greater than 10 characters")
	// ErrKeys error.
	ErrKeys = errors.New("keys not set")
)

Functions

func Configure

func Configure(o *Options) error

Configure inits the cookie store.

func CookUser

func CookUser(r *http.Request, w http.ResponseWriter) (string, error)

CookUser returns username stored in gorilla cookie.

func Flash

func Flash(r *http.Request, w http.ResponseWriter) (string, error)

Flash returns temporal flashes. TODO; make better implementation for multiple errors messages or struct.

func Handler

func Handler(h http.Handler) http.Handler

Handler middleware.

func Login

func Login() http.Handler

Login endpoint.

func Logout

func Logout() http.Handler

Logout endpoint.

Types

type Context

type Context struct {
	Username string
	Token    string
}

Context satisfies qra.Identity interface.

func (Context) Me

func (c Context) Me() string

Me method satisfies qra.Identity.

func (Context) Session

func (c Context) Session(dst interface{}) error

Session method satisfies qra.Identity.

type Options

type Options struct {
	Keys        string
	Separator   string
	SessionName string
	LoginURL    string
	LogoutURL   string
	HomeURL     string
}

Options struct.

Jump to

Keyboard shortcuts

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