data

package
v0.0.0-...-3cdf4da Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2017 License: MIT Imports: 2 Imported by: 0

README

GoDoc

Context Data

Custom yarf.ContextData implementation package that works with strings. Includes a Yarf Middleware used to set the yarf.Data object automatically.

import (
    "github.com/yarf-framework/yarf"
    "github.com/yarf-framework/extras/context/data"
    //...
)

func main() {
    y := yarf.New()
    y.Insert(new(data.SetStrData))
    
    // ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SetStrData

type SetStrData struct {
	yarf.Middleware
}

SetStrData middleware creates a new yarf.Context.Data object based on StrData type.

func (*SetStrData) PreDispatch

func (m *SetStrData) PreDispatch(c *yarf.Context) error

PreDispatch creates the StrData object and sets it on the Context.Data property.

type StrData

type StrData struct {

	// Sync Mutex
	sync.RWMutex
	// contains filtered or unexported fields
}

StrData implements the yarf.ContextData interface to be used as a simple string storage. All interface{} values passed through this methods are treated as strings.

func (*StrData) Del

func (sd *StrData) Del(key string) error

Del removes the data item and key name for a given key.

func (*StrData) Get

func (sd *StrData) Get(key string) (interface{}, error)

Get retrieves a data item by it's key name.

func (*StrData) Set

func (sd *StrData) Set(key string, data interface{}) error

Set saves a data item under a key name.

Jump to

Keyboard shortcuts

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