I'm writing an app with http Akka and i want to POST json file, with csv inside and parse it. When I use enitityToString() I get string in single line instead of string with /n.
My http server:
public static void createHttpServer(ApplicationRouter applicationRouter) {
ActorSystem actorSystem = ApplicationProperties.actorSystem;
Http http = Http.get(actorSystem);
ActorMaterializer actorMaterializer = ActorMaterializer.create(actorSystem);
Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = applicationRouter
.createRoute()
.flow(actorSystem, actorMaterializer);
http.bindAndHandle(routeFlow, ConnectHttp.toHost(ApplicationProperties.httpHost,
Integer.parseInt(ApplicationProperties.httpPort)), actorMaterializer);
}
createRoute function:
public Route createRoute() {
return route(
post(() -> route(
panelDataUpload()
)),
get(() -> route(
path("health-check", this::healthCheck)
))
);
}
panelDataUpload function:
private Route panelDataUpload() {
return path(PathMatchers
.segment("panel")
.slash("data"), () -> parameterList
(parameters -> entity(entityToString(), this::processRequestData))
);
}
And when I display String in processRequestData I get single line string without "/n" or something.
File I'm sending:
{
"table": "panelTest",
"panel-data": "header1,header2,header3
va0,va1,va2
v10,v11,v12
v20,v21,v22"
}
With curl:
curl -d @"import.txt" -H "Content-Type: application/json" -X POST http://localhost:8777/panel/data
Is there any way to get end of line marks from entity? What am i doing wrong?