I'm not sure if this is possible yet, but i'm trying to do a POST to the aerogear-controller-demo from our js libs
$( function() {
var pipeline = AeroGear.Pipeline(
{
name: "controllerPipe",
settings: {
baseURL: "http://localhost:8080/aerogear-controller-demo",
endpoint: "/cars"
}
}
);
var controllerPipe = pipeline.pipes.controllerPipe;
controllerPipe.save(
{
color: "black",
brand: "bmw"
},
{
success: function( data ) {
console.log( data );
},
error: function( error ) {
console.log( error );
}
});
});
Which should hit this route, it's modified to return the object as JSON, like i needed for the GET request
route()
.from("/cars")
.on(RequestMethod.POST)
.produces(MediaType.JSON.toString())
.to(Home.class).save(param(Car.class));
This is the request info from chrome dev tools
Request URL:http://localhost:8080/aerogear-controller-demo/cars
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:31
Content-Type:application/json
Host:localhost:8080
Origin:http://localhost:3501
Pragma:no-cache
Referer:http://localhost:3501/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
Request Payload
{"color":"black","brand":"bmw"}
Everything returns ok, but it returns null.
I noticed that in aerogear-controller, in DefaultRouteProcessor.java in the extractParameters method
Map<String, String[]> parameterMap = request.getParameterMap();
which would be blank since the values are in the request body
I'm guessing that it has something to do with the "Consume" functionality that is not yet there?
Just wanted to see if i was doing something wrong