On Sat, 02 Jul 2016 09:17:00 GMT, Sönke Ludwig wrote:
Sorry, mixed up the topic. Corrected
extractContents
is above. I didn't test this, so I'm not 100% sure that the interface generator doesn't try to access the body as a JSON object, but if it does, that would at least be easily fixable.
Seems like the return type of the before hook needs to match the type of the parameter. Otherwise I get this compile error:
../../../../.dub/packages/vibe-d-0.7.30-alpha.3/vibe-d/source/vibe/web/rest.d(970,7): Error: template std.typecons.Nullable!(int[]).Nullable.opAssign cannot deduce function from argument types !()(string), candidates are:
~/.dvm/compilers/dmd-2.071.1/osx/bin/../../src/phobos/std/typecons.d(2039,10): std.typecons.Nullable!(int[]).Nullable.opAssign()(T value)
../../../../.dub/packages/vibe-d-0.7.30-alpha.3/vibe-d/source/vibe/web/rest.d(99,45): Error: template instance vibe.web.rest.jsonMethodHandler!(foobar, 0LU, FoobarController) error instantiating
source/Application.d(62,37): instantiated from here: registerRestInterface!(FoobarController)
source/Application.d(27,34): instantiated from here: registerRestInterface!(FoobarController)
source/app.d(10,16): instantiated from here: registerController!(FoobarController)
../../../../.dub/packages/vibe-d-0.7.30-alpha.3/vibe-d/source/vibe/web/rest.d(101,37): Error: forward reference to inferred return type of function call 'filter!((p) => p.kind != ParameterKind.internal)(route.parameters)'
../../../../.dub/packages/vibe-d-0.7.30-alpha.3/vibe-d/source/vibe/web/rest.d(107,62): Error: forward reference to inferred return type of function call 'filter!((rs) => rs.all!((r) => r.method != HTTPMethod.OPTIONS))(intf.getRoutesGroupedByPattern())'
Ideally I need a more generic approach, something that works for all parameter for all rest interfaces that are registered. Not sure if it's possible to use meta programming to generate some code for that.