Am 20.11.2013 18:42, schrieb Jacob Carlborg:

On 2013-11-20 10:13, Sönke Ludwig wrote:

So it looks like two additions to the REST system would be necessary:
Allow to specify the serializer (JSON/XML/...) that is used, and allow
to specify a custom suffix for each URL (".json"/".xml"/...). Then I'd
imagine this to work in that scenario:

router.registerRestInterface!JsonStringSerializer(..., ".json");
router.registerRestInterface!XMLStringSerializer(..., ".xml");
router.registerRestInterface!HTMLStringSerializer(..., ".html");

Of course, the XML and HTML serializers would also have to be written,
but that's trivial.

One thing to think about is how query parameters will be handled in
this case. Currently all primitive types are directly converted to
string (e.g. 2.5 gets param=2.5) and complex parameters get
serialized to JSON (e.g. SomeStruct(2.5, "hello") might get
param={"field1":2.5,"field2":"hello"}). XML or HTML might be less
practical here. But JSON isn't optimal either, so maybe there is
something entirely different that could be used here instead.

I have no idea how this stuff works in vibe.d but why would you want
JSON in a query parameter?

Usually you wouldn't want that, but it was the most natural choice for
the case when someone declares a complex parameter for a GET method.
Another possibility would be to break up the struct into multiple
parameters (e.g. param_field1=2.5&param_field2=hello), but then there
are possible ambiguities and the implementation complexity grows
considerably.