wrapper

package
v0.0.0-...-99ae320 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2015 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Wrapper defines the struct to be passed back to the controller. It contains the entirety of the response and performs all marshalling and write operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	Id      bson.ObjectId `bson:"_id"`
	Updated time.Time     `bson:"updated"`
}

Wrapper structure for Sessions

type Wrapper

type Wrapper struct {
	Writer     http.ResponseWriter    // The response writer
	Request    *http.Request          // The request
	SiteConfig *configs.SiteConfig    // The configuration for the site being accessed
	Session    *Session               // Session for user
	Payload    map[string]interface{} // This is the sum of the payload that will be returned to the user
	DbSession  *mgo.Session           // The master MongoDb session that gets copied
	APIParams  []string
}

Wrapper structure required to be passed back to the Controller

func New

Constructor for the Wrapper

func (*Wrapper) DeleteAPayload

func (w *Wrapper) DeleteAPayload(n string)

Gets payload based on a keyvalue

func (*Wrapper) GetAPayload

func (w *Wrapper) GetAPayload(n string) (interface{}, error)

Gets payload based on a keyvalue

func (*Wrapper) GetPayload

func (w *Wrapper) GetPayload() map[string]interface{}

Gets entire payload

func (*Wrapper) GetSessionValue

func (w *Wrapper) GetSessionValue(n string, i interface{}) error

Get a session value by key.

func (*Wrapper) NewSession

func (w *Wrapper) NewSession() error

Session constructor

func (*Wrapper) Serve

func (w *Wrapper) Serve()

The final serve function. This will marshall the payload and serve it to the user.

func (*Wrapper) SetClasses

func (w *Wrapper) SetClasses(c string)

Helper function for the controller to easily add its final content to the Payload

func (*Wrapper) SetContent

func (w *Wrapper) SetContent(c interface{})

Helper function for the controller to easily add its final content to the Payload

func (*Wrapper) SetDynamicId

func (w *Wrapper) SetDynamicId(i string)

Helper function for the controller to easily add its final content to the Payload

func (*Wrapper) SetPayload

func (w *Wrapper) SetPayload(n string, v interface{})

Sets payload based on a keyvalue

func (*Wrapper) SetSession

func (w *Wrapper) SetSession() error

func (*Wrapper) SetSessionValue

func (w *Wrapper) SetSessionValue(k string, v interface{}) error

Get current session data

func (*Wrapper) SetTemplate

func (w *Wrapper) SetTemplate(t string)

Helper function for the controller to easily add its final content to the Payload

func (*Wrapper) Shift

func (w *Wrapper) Shift()

Shift API Params over by one

Jump to

Keyboard shortcuts

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