Hello all,
I started using vibe.d to build a REST API. I really love it !

I want to build a REST API.
I've seen vibe.http.rest and it's really good, but it seems to be lacking / forbidding a feature which I absolutely need: a way to handle [de]serialization.
(At least that's what https://github.com/rejectedsoftware/vibe.d/blob/master/examples/rest/source/app.d#L90 let me to believe)

1) The main reason is that I would like to provide different media (ContentType) to people. So far, XML, JSON, HTML.
2) I'll also use ContentType over the URL-way for versioning (I'm aware of it's drawbacks).
3) And of course, I'd like to take full advantages of it by using objects / structs in the client, not return a string that I have to pass to another function.

What I tried so far was mostly based on @before / @after attributes:

  • @before: handles the authen (and set others parameters based on the header, like the version), works like a charm;
  • @after: I tried to use it to set the format, but I need to return something (for 3), and it WILL be serialized. If I just write to HTTPServerResponse, my data get duplicated, so I needed to tell the framework how to do it. I first override toString(), which in turns called a delegate (toJson, toHtml, toXML), but no luck with that (doesn't get called?). I also thought of implementing a custom Json object, but it's a struct, so no inheritance, and that's really hacky.

So the only solution I see so far is to implement the interface in the client only (I'll use JSON only for D), and implement the server without vibe.http.rest, only using plain URLRouter and stuff.

Did I missed a point ? Is there any plan to support custom [de]serialization sooner or later ?