Re: Can't understand how to do server response with vibed

2015-12-02 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:03:13 UTC, Suliman wrote: Could anybody help me to understand how to complete HTTP response with vibed. I am sending POST request from AngularJS: $.post("http://127.0.0.1:8080/my;, total_result); where total_result is JSON string: [{"QID":3,"AID":3},

Re: Can't understand how to do server response with vibed

2015-11-30 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Sunday, 29 November 2015 at 07:37:56 UTC, Suliman wrote: On Saturday, 28 November 2015 at 23:21:21 UTC, Sebastiaan Koppe wrote: On Saturday, 28 November 2015 at 19:05:59 UTC, Suliman wrote: And also I can't understand difference between HTTPClientRequest and HTTPServerRequest If the

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
And the second question. Why I am getting next error after attempt to write to console JSON request: Error: cannot resolve type for res.writeJsonBody(T)(T data int status = HTTPStatus.OK, string content_type = "application/json; charset=UF-8", bool allow_chunked = false) void

Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
Could anybody help me to understand how to complete HTTP response with vibed. I am sending POST request from AngularJS: $.post("http://127.0.0.1:8080/my;, total_result); where total_result is JSON string: [{"QID":3,"AID":3}, {"SubAID":[4]}, {"MinArea":"10","MaxArea":"90"}] Handler is look

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 19:05:59 UTC, Suliman wrote: And also I can't understand difference between HTTPClientRequest and HTTPServerRequest If the application (vibe.d) makes a request, it is the client. If the request is made to your application, it is the server. In your case your

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 19:10:17 UTC, Suliman wrote: void action(HTTPServerRequest req, HTTPServerResponse res) { } Here is function what have two call-backs. When it's get request it's work as server, when it's send response it's work like client or I have wrong logic? Wrong

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:46:05 UTC, Suliman wrote: And the second question. Why I am getting next error after attempt to write to console JSON request: Error: cannot resolve type for res.writeJsonBody(T)(T data int status = HTTPStatus.OK, string content_type = "application/json;

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
And also I can't understand difference between HTTPClientRequest and HTTPServerRequest For example if I am getting request from web-browser what I should use? And why?

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
void action(HTTPServerRequest req, HTTPServerResponse res) { } Here is function what have two call-backs. When it's get request it's work as server, when it's send response it's work like client or I have wrong logic?

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:51:57 UTC, Suliman wrote: Eghm, sorry. Not req, but res, but again errr: void action(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.writeJsonBody); } What you want is `req.json`. Make sure that the call from angular sets the Content-Type

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:57:53 UTC, anonymous wrote: On 28.11.2015 19:51, Suliman wrote: Eghm, sorry. Not req, but res, but again errr: void action(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.writeJsonBody); } Error: no property 'writeJsonBody' for type

Re: Can't understand how to do server response with vibed

2015-11-28 Thread anonymous via Digitalmars-d-learn
On 28.11.2015 19:51, Suliman wrote: Eghm, sorry. Not req, but res, but again errr: void action(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.writeJsonBody); } Error: no property 'writeJsonBody' for type 'vibe.http.server.HTTPServerRequest' But this method are present in

Re: Can't understand how to do server response with vibed

2015-11-28 Thread anonymous via Digitalmars-d-learn
On 28.11.2015 19:46, Suliman wrote: And the second question. Why I am getting next error after attempt to write to console JSON request: Error: cannot resolve type for res.writeJsonBody(T)(T data int status = HTTPStatus.OK, string content_type = "application/json; charset=UF-8", bool

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
On Saturday, 28 November 2015 at 23:21:21 UTC, Sebastiaan Koppe wrote: On Saturday, 28 November 2015 at 19:05:59 UTC, Suliman wrote: And also I can't understand difference between HTTPClientRequest and HTTPServerRequest If the application (vibe.d) makes a request, it is the client. If the