flash

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

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

Go to latest
Published: Jun 19, 2017 License: BSD-3-Clause Imports: 3 Imported by: 3

README

flash CircleCI

Middleware flash is a tool for share data between requests for Tango.

Notice

This is a new version, it stores all data via session not cookie. And it is slightly non-compitable with old version.

Installation

go get github.com/tango-contrib/flash

Simple Example


import "github.com/tango-contrib/session"

type FlashAction struct {
    flash.Flash
}

func (x *FlashAction) Get() {
    x.Flash.Set("test", "test")
}

func (x *FlashAction) Post() {
   x.Flash.Get("test").(string) == "test"
}

func main() {
    t := tango.Classic()
    sessions := session.Sessions()
    t.Use(flash.Flashes(sessions))
    t.Any("/", new(FlashAction))
    t.Run()
}

License

This project is under BSD License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FlashName      = "tango_flash"
	FlashSeperator = "TANGOFLASH"
)

Functions

func Flashes

func Flashes(sessions *session.Sessions, opts ...Options) tango.HandlerFunc

Flashes return a FlashData handler.

Types

type Data

type Data map[string]interface{}

type Flash

type Flash struct {
	*Options
	// contains filtered or unexported fields
}

FlashData is a tools to maintain data when using across request.

func (*Flash) Add

func (f *Flash) Add(kvs Data)

func (*Flash) AddValues

func (f *Flash) AddValues(values url.Values)

func (*Flash) Data

func (f *Flash) Data() Data

func (*Flash) FlushData

func (f *Flash) FlushData() Data

func (*Flash) Get

func (f *Flash) Get(key string) interface{}

func (*Flash) Merge

func (f *Flash) Merge()

func (*Flash) Save

func (f *Flash) Save()

func (*Flash) Set

func (f *Flash) Set(key string, value interface{})

type Flasher

type Flasher interface {
	FlushData() Data
	Save()
	// contains filtered or unexported methods
}

type Options

type Options struct {
	FlashName      string
	FlashSeperator string
}

Jump to

Keyboard shortcuts

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