Not only does this answer require you to have the appropriate json
libraries to map from a JObject back to a string - It can be subtly broken
in that its doing String -> Json representation -> String transformation,
ergo, nulls and nones, whitespace and other changes are all subject to be
misrepresented compared to what was genuinely posted to the service. Use it
with caution.
On Tuesday, March 24, 2015 at 1:52:37 PM UTC, Mark Hatton wrote:
>
> Hi Robin,
>
> Have you considered using an Akka HTTP route (akin to a spray route)?
> E.g.:
>
> val route = path("saveTsta")(
> post(
> entity(as[String]){
> json =>
> System.out.println(json)
> complete(StatusCodes.OK)
> }
> )
> )
>
> Complete gist: https://gist.github.com/markhatton/17b586982f1beab30425
>
> Mark
>
>
>
>
>
> On Friday, January 16, 2015 at 1:26:48 PM UTC, Robin Bakkerus wrote:
>>
>> Can some one help me with (I think) a very simply question, but one I
>> could not figure out myself yet.
>>
>> It is about how extract the (json) string out of the RequestEntity,
>> inside a HttpRequest
>>
>> From the command line I give a command like this:
>> curl -i -H "Accept: application/json" -H "Content-Type:application/json"
>> -X POST --data '{"value":{"id":1}' http://localhost:8000/saveTsta
>>
>> And this should be handled by an Akka-http server like this:
>>
>> def requestHandler(req: HttpRequest): Future[HttpResponse] = req match {
>> case HttpRequest(POST, Uri.Path("/saveTsta"), _, _, _) =>
>> saveTsta(req)
>> case _: HttpRequest =>
>> unknownReq(req)
>> }
>>
>>
>> def saveTsta(req: HttpRequest): Future[HttpResponse] = {
>> val entity:RequestEntity = req.entity
>>
>> val json:String = how_do_get_the_json_data_out_of(entity) ???
>> }
>>
>> Txs in advance
>>
>
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user
google-group soon.
** This group will soon be put into read-only mode, and replaced by
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>>
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/akka-user/b76d009d-d0ac-4e62-8a88-c37655673128%40googlegroups.com.