Documentation ¶
Index ¶
- func GetAbsolutePath(dir string) (string, error)
- func StaticServer(cfg *config.Config) (string, bool, http.Handler)
- type App
- func (a *App) AddController(ctrlfn func() controller.Controller, middlewares ...interface{})
- func (a *App) Init() error
- func (a *App) LoadConfig() error
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) SetConfigPath(dir string)
- func (a *App) SetNotFoundHandler(h http.Handler) error
- func (a *App) SetView(vw view.View)
- type StaticServerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAbsolutePath ¶
getAbsolutePath returns the absolute path to dir. If the dir is relative, then we add the current working directory. Checks are made to ensure the directory exist. In case of any error, an empty string is returned.
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 ¶
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) LoadConfig ¶
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 ¶
SetConfigPath sets the directory path to search for the config files.
func (*App) SetNotFoundHandler ¶
SetNotFoundHandler this sets the hadler that is will execute when the route is not found.
type StaticServerFunc ¶
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.