www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Debugging bad requests with vibe

reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
I have set up a vibe.d rest interface (on a server) and have a 
client on my machine.

struct Observation
{
     string desc;
     DateTime time;
}

interface Obsever
{
      property void observe(Observation ra);
}

void main()
{
     auto test = Observation("a duck", 
cast(DateTime)Clock.currTime(UTC()));

     auto client = new RestInterfaceClient! 
Obsever("http://example.com/observation");
     client. observe = test; // 400
}

I' pretty sure the url is correct because other ones give 404.

Is there a way I can see/log what requests are being made? I can 
change both the client and server.
Feb 08 2018
next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
wrote:
 I have set up a vibe.d rest interface (on a server) and have a 
 client on my machine.

 struct Observation
 {
     string desc;
     DateTime time;
 }

 interface Obsever
 {
      property void observe(Observation ra);
 }

 void main()
 {
     auto test = Observation("a duck", 
 cast(DateTime)Clock.currTime(UTC()));

     auto client = new RestInterfaceClient! 
 Obsever("http://example.com/observation");
     client. observe = test; // 400
 }

 I' pretty sure the url is correct because other ones give 404.

 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
Never mind, it was because I was accidentally shadowing that path with a get on the server.
Feb 08 2018
parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Thursday, 8 February 2018 at 20:24:19 UTC, Nicholas Wilson 
wrote:
 On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
 wrote:
 I have set up a vibe.d rest interface (on a server) and have a 
 client on my machine.

 struct Observation
 {
     string desc;
     DateTime time;
 }

 interface Obsever
 {
      property void observe(Observation ra);
 }

 void main()
 {
     auto test = Observation("a duck", 
 cast(DateTime)Clock.currTime(UTC()));

     auto client = new RestInterfaceClient! 
 Obsever("http://example.com/observation");
     client. observe = test; // 400
 }

 I' pretty sure the url is correct because other ones give 404.

 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
Never mind, it was because I was accidentally shadowing that path with a get on the server.
Hmm, nope it wasn't that.
Feb 09 2018
prev sibling parent reply Seb <seb wilzba.ch> writes:
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
wrote:
 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
-v and -vv
Feb 09 2018
next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
 On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
 wrote:
 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
-v and -vv
All that gives me is a bunch of [FAC3BFF6:FAC451F6 dia] Actively closing TCP connection is there a way to get the JSON being sent?
Feb 09 2018
next sibling parent Arjan <arjan ask.me.to> writes:
On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote:
 On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
 On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
 wrote:
 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
-v and -vv
All that gives me is a bunch of [FAC3BFF6:FAC451F6 dia] Actively closing TCP connection is there a way to get the JSON being sent?
Wireshark?
Feb 09 2018
prev sibling parent tetyys <tetyys tetyys.com> writes:
On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote:
 On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
 On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
 wrote:
 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
-v and -vv
All that gives me is a bunch of [FAC3BFF6:FAC451F6 dia] Actively closing TCP connection is there a way to get the JSON being sent?
Try Fiddler, great tool too
Feb 09 2018
prev sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
 On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
 wrote:
 Is there a way I can see/log what requests are being made? I 
 can change both the client and server.
-v and -vv
So it turns out that structs do not work as parameters TO rest interface functions. https://github.com/vibe-d/vibe.d/issues/2067
Feb 09 2018
parent rjframe <dlang ryanjframe.com> writes:
On Fri, 09 Feb 2018 15:48:54 +0000, Nicholas Wilson wrote:

 On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
 On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote:
 Is there a way I can see/log what requests are being made? I can
 change both the client and server.
-v and -vv
So it turns out that structs do not work as parameters TO rest interface functions. https://github.com/vibe-d/vibe.d/issues/2067
I have a project doing this; I think I solved that (or something) with: ``` path("/api/") interface RestAPI { // stuff } ``` I cannot reproduce your problem with that code though to see if it will work.
Feb 09 2018