ApiProvider

Everything should derive from this instead of the old struct namespace used before Your class must provide a default constructor.

Members

Functions

_catchAll
FileResource _catchAll(string path)

If the given url path didn't match a function, it is passed to this function for further handling. By default, it throws a NoSuchFunctionException. Overriding it might be useful if you want to serve generic filenames or an opDispatch kind of thing. (opDispatch itself won't work because it's name argument needs to be known at compile time!)

_defaultPage
Document _defaultPage()

If the user goes to your program without specifying a path, this function is called.

_getCsrfInfo
string[string] _getCsrfInfo()

Gets the CSRF info (an associative array with key and token inside at least) from the session. Note that the actual token is generated by the Session class.

_getGenericContainer
Element _getGenericContainer()

forwards to _getGenericContainer

_getGenericContainer
Element _getGenericContainer(string containerName)

When the html document envelope is used, this function is used to get a html element where the return value is appended. It's the main function to override to provide custom HTML templates.

_initialize
void _initialize()

Override this if you have initialization work that must be done *after* cgi and reflection is ready. It should be used instead of the constructor for most work.

_initializePerCall
void _initializePerCall()

This one is called at least once per call. (_initialize is only called once per process)

_postProcess
void _postProcess(Document document)

we have to add these things to the document...

_registerPostProcessor
void _registerPostProcessor(void delegate(Document) pp)
void _registerPostProcessor(void delegate(Element) pp)
void _registerPostProcessor(void function(Document) pp)
void _registerPostProcessor(void function(Element) pp)

On each call, you can register another post processor for the generated html. If your delegate takes a Document, it will only run on document envelopes (full pages generated). If you take an Element, it will apply on almost any generated html.

_sitemap
Element _sitemap()

Returns a list of links to all functions in this class or sub-classes You can expose it publicly with alias: "alias _sitemap sitemap;" for example.

_style
string _style()

Returns the stylesheet for this module. Use it to encapsulate the needed info for your output so the module is more easily reusable Override this to provide your own stylesheet. (of course, you can always provide it via _catchAll or any standard css file/style element too.)

addCsrfTokens
void addCsrfTokens(Document document)

Adds CSRF tokens to the document for use by script (required by the Javascript API) and then calls addCsrfTokens(document.root) to add them to all POST forms as well.

addCsrfTokens
void addCsrfTokens(Element element)

This adds CSRF tokens to all forms in the tree

checkCsrfToken
void checkCsrfToken()

override this to change cross-site request forgery checks.

disableRedirects
void disableRedirects()

Temporarily disables the redirect() call.

enableRedirects
void enableRedirects()

Re-enables redirects. Call this once for every call to disableRedirects.

ensureGoodPost
void ensureGoodPost()

Shorthand for ensurePost and checkCsrfToken. You should use this on non-indempotent functions. Override it if doing some custom checking.

redirect
string redirect(string location, bool important, string status)

This tentatively redirects the user - depends on the envelope fomat You can temporarily disable this using disableRedirects()

stylesheet
string stylesheet()

Returns the combined stylesheet of all child modules and this module

Variables

_errorFunction
Document delegate(Throwable) _errorFunction;

When in website mode, you can use this to beautify the error message

Inherited Members

From WebDotDBaseType

cgi
Cgi cgi;

lower level access to the request

exceptionExaminer
void exceptionExaminer(Throwable e)

use this to look at exceptions and set up redirects and such. keep in mind it does NOT change the regular behavior

_postProcess
void _postProcess(Document document)

Override this if you want to do something special to the document You should probably call super._postProcess at some point since I might add some default transformations here. By default, it forwards the document root to _postProcess(Element).

_postProcessElement
void _postProcessElement(Element element)

Override this to do something special to returned HTML Elements. This is ONLY run if the return type is(: Element). It is NOT run if the return type is(: Document).

ensurePost
void ensurePost()

convenience function to enforce that the current method is POST. You should use this if you are going to commit to the database or something.

Suggestion Box / Bug Report