A standard Ufront Application for executing requests on the server.

This extends HttpApplication for a "batteries included" way to set up your server-side Ufront app.

Out of the box it provides:

  • The MVCHandler for macro powered routing and a model / view / controller style of responding to requests.
  • The RemotingHandler for automatic Haxe powered remoting APIs.
  • Tracing to a browser console during a web request or a remoting call, based on your UfrontConfiguration.
  • Default URL Filtering rules, based on your UfrontConfiguration.

Ufront uses minject.Injector for dependency injection, and UfrontApplication adds several things to the injector, depending on your configuration:

  • All of the controllers specified in your configuration (By default: every Controller imported into your app).
  • All of the APIs specified in your configuration (by default: every UFApi imported into your app).
  • The UFAsyncApi versions of any UFApi classes injected above.
  • A singleton of the UFViewEngine specified in your UfronConfiguration.
  • The implementation of UFHttpSession you chose in your UfrontConfiguration, to be instantiated on each request.
  • The implementation of UFAuthHandler you chose in your UfrontConfiguration, to be instantiated on each request.
  • A String named viewPath for the path to your view folder, specified in your UfrontConfiguration.
  • A String name scriptDirectory, containing the path to the directory the current app is located in.
  • A String name contentDirectory, containing the path to the content directory specified in your configuration.

Futher injections may take place in various middleware / handlers also.

Constructor

new (?optionsIn:UfrontConfiguration)

Initialize a new UfrontApplication with the given configurations.

Parameters:

?optionsIn

Options for UfrontApplication. See DefaultUfrontConfiguration for details. Any missing values will imply defaults should be used.

Fields

read only configuration:UfrontConfiguration

The configuration that was used when setting up the application.

This is set during the constructor. Changing values of this object is not likely to have any effect.

read only mvcHandler:MVCHandler

The MVC handler used for this application.

This is made accessible for unit testing and logging purposes, you are unlikely to need to access it directly for anything else.

read only remotingHandler:RemotingHandler

The remoting handler used for this application.

It is automatically set up if a UFApiContext class is supplied.

This is made accessible for unit testing and logging purposes, you are unlikely to need to access it directly for anything else.

read only viewEngine:UFViewEngine

The view engine being used with this application.

It is configured using the viewEngine property on your UfrontConfiguration.

Methods

addTemplatingEngine (engine:TemplatingEngine):UfrontApplication

Add support for a templating engine to your view engine.

execute (httpContext:HttpContext):Surprise<Noise, Error>

Execute the current request.

The first time this runs, this.initOnFirstExecute() will be called, which runs some more initialization that requires the HttpContext to be ready before running.

inline loadApiContext (apiContext:Class<UFApiContext>):UfrontApplication

Shortcut for remotingHandler.loadApiContext(). See RemotingHandler.loadApiContext() for details.