app

package
v0.0.0-...-699b668 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StaticServer

func StaticServer(cfg *config.Config) (string, bool, http.Handler)

StaticServer implements StaticServerFunc.

This uses the http.Fileserver to handle static assets. The routes prefixed with /static/ are static asset routes by default.

Types

type App

type App struct {
	Router       *router.Router
	Config       *config.Config
	View         view.View
	Log          logger.Logger
	Model        *models.Model
	ConfigPath   string
	StaticServer StaticServerFunc
	SessionStore sessions.Store
	// contains filtered or unexported fields
}

App is the main utron application.

func NewApp

func NewApp() *App

NewApp creates a new bare-bone utron application. To use the MVC components, you should call the Init method before serving requests.

func NewMVC

func NewMVC(cfg ...string) (*App, error)

NewMVC creates a new MVC utron app. If cfg is passed, it should be a directory to look for the configuration files. The App returned is initialized.

func (*App) AddController

func (a *App) AddController(ctrlfn func() controller.Controller, middlewares ...interface{})

AddController registers a controller, and middlewares if any is provided.

func (*App) Init

func (a *App) Init() error

Init initializes the MVC App.

func (*App) ServeHTTP

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http requests. It can be used with other http.Handler implementations.

func (*App) SetConfigPath

func (a *App) SetConfigPath(dir string)

SetConfigPath sets the directory path to search for the config files.

func (*App) SetNotFoundHandler

func (a *App) SetNotFoundHandler(h http.Handler) error

SetNotFoundHandler this sets the hadler that is will execute when the route is not found.

type StaticServerFunc

type StaticServerFunc func(*config.Config) (prefix string, strip bool, h http.Handler)

StaticServerFunc is a function that returns the static assetsfiles server.

The first argument retrued is the path prefix for the static assets. If strp is set to true then the prefix is going to be stripped.

Jump to

Keyboard shortcuts

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