Hello,

I'm having a bit of trouble being able to do a POST. My get
works (getStatus), but the postCalc method keeps throwing an
error for some reason. From what I can tell, my code is valid
and I've tried various permutations just to get something to work
to no avail. My goal is to find a way to accept two or more
parameters and return a result.

Code:

import vibe.d;

class TestInterface
{

  string getStatus() { return "running"; }
  int postCalc(int val1, int val2)
  {
      return val1 + val2;
  }

}

static this()
{

  auto router = new UrlRouter;

  registerRestInterface(router, new TestInterface, "/");

  auto settings = new HttpServerSettings;
  settings.port = 8080;

  listenHttp(settings, router);

}

Curl command:

curl -i -XPOST -H "Content-Type: text/json"
http://localhost:8080/calc -d '{"val1": 1, "val2": 2}'

And the error:

500 - Internal Server Error

Internal Server Error

Internal error information:
object.Exception@/home/dev/dev/vibe.d/source/vibe/data/json.d(609):
Trying to access JSON of type Undefined as Json[string].

/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(pure
@safe bool std.exception.enforce!(bool).enforce(bool, lazy
const(char)[], immutable(char)], uint)+0x2c) [0x81a93d8]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(const(void
function())
vibe.data.json.Json.checkType!(vibe.data.json.Json[immutable(char)[]]).heckType+0x3f)
[0x81a9553]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(ref
vibe.data.json.Json
vibe.data.json.Json.opIndex(immutable(char)[])+0x3c) [0x81a7c98]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(void
delegate(vibe.http.server.HttpServerRequest,
vibe.http.server.HttpServerResponse)
vibe.htp.rest.jsonMethodHandler!(app.TestInterface, "postCalc",
int function(int,
int)).jsonMethodHandler(app.TestInterface).void
handler(vibe.http.server.HttpServeRequest,
vibe.http.server.HttpServerResponse)+0x145) [0x81da48d]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(void
vibe.http.router.UrlRouter.handleRequest(vibe.http.server.HttpServerRequest,
vibe.http.sever.HttpServerResponse)+0x120) [0x8169680]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(bool
vibe.http.server.handleRequest(vibe.stream.stream.Stream,
immutable(char)[], vibe.http.sever.HTTPServerListener, ref
vibe.http.server.HttpServerSettings)+0xdec) [0x81b5ce0]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(void
vibe.http.server.handleHttpConnection(vibe.core.driver.TcpConnection,
vibe.http.server.HTPServerListener)+0x143) [0x81b4e7b]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(void
vibe.http.server.listenHttpPlain(vibe.http.server.HttpServerSettings,
void delegate(vibe.ttp.server.HttpServerRequest,
vibe.http.server.HttpServerResponse)).void
doListen(vibe.http.server.HttpServerSettings,
vibe.http.server.HTTPServerListener, imutable(char)[]).void
__lambda20(vibe.core.driver.TcpConnection)+0x27) [0x81b2c47]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(extern
(C) void vibe.core.drivers.libevent2_tcp.onConnect(int, short,
void
).void ClientTask.eecute()+0x200) [0x81e7054]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(void
vibe.core.core.CoreTask.run()+0x5d) [0x81ba061]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(void
core.thread.Fiber.run()+0x21) [0x8212e61]
/tmp/.rdmd-1000/rdmd-app.d-BE457B9C3E08EC5E9E05D1C46EE22220/app(fiber_entryPoint+0x4e)
[0x8212d9e]