app

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

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

Go to latest
Published: Apr 26, 2016 License: MIT Imports: 23 Imported by: 1

README

Flotilla Build Status GoDoc Coverage Status license

Documentation

Overview

Package app contains core structures for building flotilla applications: App, Configuration, and Environment. Additionally, package app provides management of key application functions through Environment: determination of operation mode, creation of state, logging, and management of extensions. App Configuration Environment

  • Mode
  • State
  • Logging
  • Extensions

Index

Constants

This section is empty.

Variables

View Source
var (
	FlotillaPath string
)

Functions

func BuiltInExtension

func BuiltInExtension(a *App) extension.Extension

Provided an App instance, BuiltInExtension returns a default extension.Extension that includes extensions for cookies, responses, and sessions, as well as several assorted App & State dependent extension functions.

func ModeIs

func ModeIs(s state.State, is string) bool

Given State and a string denoting a Mode, ModeIs returns a boolean value for that mode. If mode string is does not exist, returns false.

func Stored

func Stored(s state.State) store.Store

Provide a State, Stored returns a store.Store instance.

func StoredString

func StoredString(s state.State, key string) string

Provided a State, and a key string, StoreString queries the associated Store returning the value corresponding to the key, or a nil string.

Types

type App

type App struct {
	engine.Engine
	Configuration
	Environment
	blueprint.Blueprints
	// contains filtered or unexported fields
}

App is the cxre structure for a flotilla application, implementing the Engine, Configuration, Environment, and Blueprints interfaces.

func Base

func Base(name string, conf ...Config) *App

Base returns an intialized App with crucial and the provided ConfigurationFns immediately applied.

func Empty

func Empty(name string) *App

Empty returns an App instance with the provided name.

func New

func New(name string, conf ...Config) *App

New returns a default Base initialized App with static directory plus any provided configuration. Note: ConfigurationFn supplied to New are not run until the App is configured. If you need to modify certain base functionality(e.g. custom engine, environment, or blueprints), start with Base instead of New.

func (*App) Name

func (a *App) Name() string

Returns the App name as a string.

func (*App) Run

func (a *App) Run(addr string)

Run checks the App is configured, configuring and panicing on errors, then starts the App listening at the provided address.

func (*App) ServeHTTP

func (a *App) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

ServeHTTP function for the App

type Config

type Config interface {
	Order() int
	Configure(*App) error
}

func Assets

func Assets(as ...asset.AssetFS) Config

Assets returns a ConfigurationFn adding the provided AssetFS to the app Environment Assets.

func DefaultConfig

func DefaultConfig(fn ConfigFn) Config

func Extend

func Extend(fxs ...extension.Extension) Config

Extend returns a ConfigurationFn that adds the provided extension.Extensions to the app Environment.

func Mode

func Mode(mode string, value bool) Config

Mode returns a ConfigurationFn for the mode and value, e.g. Mode("testing", true).

func NewConfig

func NewConfig(order int, fn ConfigFn) Config

func Store

func Store(items ...string) Config

Store returns a ConfigurationFn that adds key value items to the environment Store in the form of "key:value".

type ConfigFn

type ConfigFn func(*App) error

type Configuration

type Configuration interface {
	AddConfig(...Config)
	AddFn(...ConfigFn)
	Configure() error
	Configured() bool
}

type Environment

Environment is an interface for central storage and access of crucial app functionality. These include State creation, Logging, and app Mode determination and setting, in addition to package external Assets, Extension, Session, Static, Store, and Templates.

type Logr

type Logr interface {
	log.Logger
	SwapLogger(log.Logger)
}

Logr is an interface to logging that implements flotilla/log.Logger as well as swap method for changing the Logger when needed.

func DefaultLogr

func DefaultLogr() Logr

DefaultLogr returns the default flotilla Logger.

type Modr

type Modr interface {
	GetMode(string) bool
	SetMode(string, bool) error
}

Modr is an interface for managing any number of modes.

func DefaultModr

func DefaultModr() Modr

DefaultModr returns a default Modr to manage Development, Production, and Testing modes.

type RequestFiles

type RequestFiles map[string][]*multipart.FileHeader

RequestFiles is a map keyed to string containing values of array of mulitpart.FileHeader.

func Files

func Files(s state.State) RequestFiles

Files extracts uploaded files from http.Request, specifically though request.MultipartForm.File.

type StateMakerFn

type StateMakerFn func(a *App) state.Make

A StateMakerFn is a function type taking an App instance, and providing a state.Make function.

type Statr

type Statr interface {
	StateFunction(a *App) state.Make
	SwapStateFunction(StateMakerFn)
}

Statr is an interface providing a StateMakerFn to the app in addition to functionality to change this function as needed.

func DefaultStatr

func DefaultStatr() Statr

The default flotilla Statr.

Directories

Path Synopsis
extensions

Jump to

Keyboard shortcuts

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