Discussion:
What's the best way to turn a Aleph raw stream to a String?
Malcolm Sparks
2015-11-26 09:46:19 UTC
Permalink
This should be easy but I'm struggling with something that I thought should
be easy and want to ask the group for help.

I've got a Aleph request body stream (raw-stream? true), so it's a manifold
stream of Netty buffers. I want to turn it into a String (I know the memory
implications are OK and I know the encoding I want the String to be).

What's the most idiomatic way of doing that? Can I use byte-streams or do I
need something from manifold?
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Keith Irwin
2015-11-30 05:13:12 UTC
Permalink
For me (decoding to json), it’s:

(:require [byte-streams :as bs])

(-> req :body bs/to-string (json/read-str :key-fn keyword))

I think I’ve seen that in a lot of the examples, so I’m guessing it’s idiomatic.
This should be easy but I'm struggling with something that I thought should be easy and want to ask the group for help.
I've got a Aleph request body stream (raw-stream? true), so it's a manifold stream of Netty buffers. I want to turn it into a String (I know the memory implications are OK and I know the encoding I want the String to be).
What's the most idiomatic way of doing that? Can I use byte-streams or do I need something from manifold?
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Zach Tellman
2015-11-30 17:53:23 UTC
Permalink
Yes, this is the standard way to do the conversion.
Post by Keith Irwin
(:require [byte-streams :as bs])
(-> req :body bs/to-string (json/read-str :key-fn keyword))
I think I’ve seen that in a lot of the examples, so I’m guessing it’s
idiomatic.
This should be easy but I'm struggling with something that I thought
should be easy and want to ask the group for help.
I've got a Aleph request body stream (raw-stream? true), so it's a
manifold stream of Netty buffers. I want to turn it into a String (I know
the memory implications are OK and I know the encoding I want the String to
be).
What's the most idiomatic way of doing that? Can I use byte-streams or do
I need something from manifold?
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...