vibe.web.web
Implements a declarative framework for building web interfaces.
This module contains the sister funtionality to the vibe.web.rest module. While the REST interface generator is meant for stateless machine-to-machine communication, this module aims at implementing user facing web services. Apart from that, both systems use the same declarative approach.
See registerWebInterface for an overview of how the system works.
Copyright
Types 5
Encapsulates settings used to customize the generated web interface.
string urlPrefixbool ignoreTrailingSlashMaps a web interface member variable to a session field.
Setting a SessionVar variable will implicitly start a session, if none has been started yet. The content of the variable will be stored in the session store and is automatically serialized and deserialized.
Note that variables of type SessionVar must only be used from within handler functions of a class that was registered using
registerWebInterface. Also note that two different session
variables with the same name parameter will access the same underlying data.
T m_initValuevoid opAssign(T new_value)this(T init_val)Initializes a session var with a constant value.__traits(identifier, DISPLAY_METHOD) displayMethodNameErrorParamType getError(Exception ex, string field)GetErrorParamType(size_t idx)NestedNameStyle valueHTTPServerRequest reqHTTPServerResponse resstring languagestring function(string, string) @safe trstring function(string, string, int, string) @safe tr_pluralFunctions 16
URLRouter registerWebInterface(C : Object, MethodStyle method_style = MethodStyle.lowerUnderscored)(URLRouter router, C instance, WebInterfaceSettings settings = null)Registers a HTTP/web interface based on a class instance.string trWeb(string text, string context = null) @safeTranslates text based on the language of the current web request.@property errorDisplay(alias DISPLAY_METHOD)()Attribute to customize how errors/exceptions are displayed.NestedNameStyleAttribute nestedNameStyle(NestedNameStyle style)Determines how nested D fields/array entries are mapped to form field names. Note that this attribute only works if applied to the class.void handleRequest(string M, alias overload, C, ERROR...)(HTTPServerRequest req, HTTPServerResponse res, C instance, WebInterfaceSettings settings, ERROR error) if (ERROR.length <= 1)RequestContext createRequestContext(alias handler)(HTTPServerRequest req, HTTPServerResponse res)Variables 1
TaskLocal!RequestContext s_requestContextTemplates 1
Renders a Diet template file to the current HTTP response.
This function is equivalent to vibe.http.server.render, but implicitly writes the result to the response object of the currently processed request.
Note that this may only be called from a function/method registered using registerWebInterface.
In addition to the vanilla render function, this one also makes additional functionality available within the template:
- The
reqvariable that holds the current request object - If the
@translationContextattribute us used, enables thebuilt-in i18n support of Diet templates