Can create service in Cassablansa to support AngularJS?

Dec 23, 2014 at 3:26 AM
My focus communication between Casablansa back-end services and AngularJS. AngularJS use for implement front-end interactive with user. After front-end send detail on JSON to back-end on Casablansa REST web service.

Why use Casablansa & AngularJS ?

1) AngularJS support REST-full service by communication with JSON
2) Casablanca can parses string from JSON object when Http method on AngularJS calls to back-end service.
3) Need performance responses information from service send back to front-end. I supposes Casablanca use C++. It's can push high performance to service implement in native language.

Who have any idea? I read C# service supports AngularJS such link here[1,2].

[1] http://henriquat.re/server-integration/signalr/integrateWithSignalRHubs.html
[2] http://weblogs.asp.net/dwahlin/using-an-angularjs-factory-to-interact-with-a-restful-service
Coordinator
Dec 23, 2014 at 7:19 PM
Hi rchatsiri,

The C++ Rest SDK contains a library HTTP server that can be used to author a REST service. Take a look at our http_listener for some starting documentation and the reference docs. Please note the main focus of this library has been for client side applications so our http_listener hasn't received the same amount of attention as our http_client. We haven't really done any performance work with the http_listener.

Steve
Dec 25, 2014 at 8:09 AM
Edited Dec 25, 2014 at 8:10 AM
Hello Steve,

Yes, You advise focus in http_client code of Casablanca. My view, http_listener maybe read follow as format below. It's example code send POST method to service and message decoded in last below. Opportunities to change http_listener to recevied GET/POST from other client not depend on http_client code of cplusplus. Where point of source code in parse string when client send http request to server?


Example:
var app = 'AirFare';
var d1 = new Date();
var d2 = new Date();
$http({
    url: '/api/test',
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    data: {application: app, from: d1, to: d2}
});
After read format of header over network as below.
Content-Length:91
Content-Type:application/json
Host:localhost:1234
Origin:http://localhost:1234
Referer:http://localhost:1234/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36
X-Requested-With:XMLHttpRequest
Request Payload
{"application":"AirFare","from":"2013-10-10T11:47:50.681Z","to":"2013-10-10T11:47:50.681Z"}
[1] http://stackoverflow.com/questions/17547227/angular-js-post-request-not-sending-json-data
Coordinator
Dec 30, 2014 at 7:10 PM
Hi rchatsiri,

I'm really having trouble understanding exactly what you are asking for. What are you stuck on or do you need help with? Take a look at one of our http_listener samples CasaLens for some example http_listener code. If you need to process a POST request in a server you can hook up a callback for the POST method with http_listener::support(methods::POST, ...). Then when your callback is invoked you can use the http_request::extract_json() method to get the request body as a JSON object, you also could get it as a string with http_request::extract_string().

Steve