Function applyParametersFromAssociativeArray

Overload group

Tries to apply all named arguments in args to func.

If it succeeds it calls the function with req, res (if it has one parameter of type HttpServerRequest and one of type HttpServerResponse), and all the values found in args.

If any supplied argument could not be applied or the method requires more arguments than given, the method returns false and does not call func. In this case error gets filled with some string describing which parameters could not be applied. Exceptions are not used in this situation, because when traversing overloads this might be a quite common scenario.

Prototypes

bool applyParametersFromAssociativeArray((Func))(
  HttpServerRequest req,
  HttpServerResponse res,
  Func func,
  out string error
);

Calls

applyParametersFromAssociativeArray!(Func,Func)(req, res, func, error), if you want to handle overloads of func, use the second version of this method and pass the overload alias as first template parameter. (For retrieving parameter names)

See_Also

formMethodHandler

Parameters

Parameter nameDescription
req The HttpServerRequest object that gets queried for form data (req.query for GET requests, req.form for POST requests) and that is passed on to func, if func has a parameter of matching type. Each key in the form data must match a parameter name, the corresponding value is then applied. HttpServerRequest and HttpServerResponse arguments are excluded as they are qrovided by the passed req and res objects.
res The response object that gets passed on to func if func has a parameter of matching type.
error This string will be set to a descriptive message if not all parameters could be matched.

Returns

true if successful, false otherwise. private

Overload group

Overload which takes additional parameter for handling overloads of func. private

Prototypes

bool applyParametersFromAssociativeArray((alias Overload,Func))(
  HttpServerRequest req,
  HttpServerResponse res,
  Func func,
  out string error
);

Authors

Sönke Ludwig, Jan Krüger

Copyright

© 2012 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.