Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for new array handling mechanisms. #2266

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions web/vibe/web/web.d
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ import std.encoding : sanitize;
query/form fields, the following rules are applied:

$(UL
$(LI An array of values is mapped to
$(LI A dynamic array of values is mapped to
`<parameter_name>_<index>`, where `index`
denotes the zero based index of the array entry. The length
of the array is determined by searching for the first
non-existent index in the set of form fields.)
denotes the zero based index of the array entry. Any missing
indexes will be left as their `init` value. Arrays can also be
passed without indexes using the name `<parameter_name>_`. They
will be added in the order they appear in the form data or
query. Mixed styles can also be used, non-indexed elements will
be used to fill in missing indexes, or appended if no missing
index exists. Duplicate indexes are ignored)
$(LI A static array of values is mapped identically to dynamic
arrays, except that all elements must be present in the query
or form data, and indexes or non-indexed data beyond the size
of the array is ignored.)
$(LI $(D Nullable!T) typed parameters, as well as parameters with
default values, are optional parameters and are allowed to be
missing in the set of form fields. All other parameter types
Expand All @@ -102,7 +110,9 @@ import std.encoding : sanitize;
a static $(D fromStringValidate) method, a static $(D fromString)
method, using $(D std.conv.to!T).)
$(LI Any of these rules can be applied recursively, so that it is
possible to nest arrays and structs appropriately.)
possible to nest arrays and structs appropriately. Note that
non-indexed arrays used recursively will be ignored because of
the nature of that mechanism.)
)

Special_parameters:
Expand Down Expand Up @@ -132,7 +142,8 @@ import std.encoding : sanitize;

$(D @before), $(D @after), $(D @errorDisplay),
$(D @vibe.web.common.method), $(D @vibe.web.common.path),
$(D @vibe.web.common.contentType)
$(D @vibe.web.common.contentType),
$(D @nestedNameStyle)

The `@path` attribute can also be applied to the class itself, in which
case it will be used as an additional prefix to the one in
Expand Down Expand Up @@ -735,7 +746,7 @@ unittest {
@nestedNameStyle(NestedNameStyle.d)
class MyService {
// expects fields in D native style:
// "items.entries[0]", "items.entries[1]", ...
// "items.entries[0]", "items.entries[1]", "items.entries[]", ...
void postItems(Items items)
{

Expand Down