flight

package
v0.0.0-...-d205b4b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2017 License: MIT Imports: 12 Imported by: 0

README

This folder contains the context package that every controller function can use for access to the database connection, views, and other configurations loaded from env.json.

Reference: http://blue-jay.github.io/configuration/

Documentation

Overview

Package flight provides access to the application settings safely.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reset

func Reset()

Reset will delete all package globals

func StoreConfig

func StoreConfig(ci env.Info)

StoreConfig stores the application settings so controller functions can access them safely.

func StoreDB

func StoreDB(db *sqlx.DB)

StoreDB stores the database connection settings so controller functions can access them safely.

func StoreXsrf

func StoreXsrf(x xsrf.Info)

StoreXsrf sets the csrf configuration.

func Xsrf

func Xsrf() xsrf.Info

Xsrf returns the csrf configuration.

Types

type Info

type Info struct {
	Config env.Info
	Sess   *sessions.Session
	UserID string
	W      http.ResponseWriter
	R      *http.Request
	View   view.Info
	DB     *sqlx.DB
}

Info structures the application settings.

func Context

func Context(w http.ResponseWriter, r *http.Request) Info

Context returns the application settings.

func (*Info) FlashError

func (c *Info) FlashError(err error)

FlashError saves an error flash and logs the error.

func (*Info) FlashErrorGeneric

func (c *Info) FlashErrorGeneric(err error)

FlashErrorGeneric saves a generic error flash and logs the error.

func (*Info) FlashNotice

func (c *Info) FlashNotice(message string)

FlashNotice saves a notice flash.

func (*Info) FlashSuccess

func (c *Info) FlashSuccess(message string)

FlashSuccess saves a success flash.

func (*Info) FlashWarning

func (c *Info) FlashWarning(message string)

FlashWarning saves a warning flash.

func (*Info) FormValid

func (c *Info) FormValid(fields ...string) bool

FormValid determines if the user submitted all the required fields and then saves an error flash. Returns true if form is valid.

func (*Info) Param

func (c *Info) Param(name string) string

Param gets the URL parameter.

func (*Info) Redirect

func (c *Info) Redirect(urlStr string)

Redirect sends a temporary redirect.

func (*Info) Repopulate

func (c *Info) Repopulate(v map[string]interface{}, fields ...string)

Repopulate fills the forms on the page after the user submits.

Jump to

Keyboard shortcuts

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