[erlang-questions] Webmachine Binary Request Strings
Loïc Hoguin
essen@REDACTED
Mon Dec 19 22:39:34 CET 2011
You can check out my implementation here for Cowboy:
https://github.com/extend/cowboy/blob/master/src/cowboy_http_rest.erl
Clean straightforward code was one of the big goals of this work. It has
few differences with Webmachine, but people have been converting
resources from Webmachine to Cowboy without much pain. And Cowboy
already had a dispatcher so it was really just a matter of writing the
decision code.
Of course I'm open to any comment you may have about it, good or bad.
On 12/19/2011 10:34 PM, Andrew Berman wrote:
> Ah, yes, I agree we would need a SimpleBridgeBinary and then go the
> opposite way if a web server doesn't support binary (binary_to_list). I
> don't think that would be too difficult to implement. The Webmachine
> decision core is the more difficult part but not too difficult as it
> has been implemented in many other languages which might make the
> decisioning a bit easier to follow.
>
> On Mon, Dec 19, 2011 at 1:27 PM, Loïc Hoguin <essen@REDACTED
> <mailto:essen@REDACTED>> wrote:
>
> SimpleBridge is nice, but it doesn't solve the OP's issue, which is
> that all the lists are being converted to binary when encoding into
> JSON, so he wants a binary webmachine to avoid converting from lists
> to binary all the time. I believe the implementation added to Cowboy
> recently does what the OP needs. On the other hand it's definitely
> tied to Cowboy and that should be taken into consideration when
> deciding what to use. It's also still considered experimental,
> although I've had good reports so far.
>
> Now if there was a SimpleBinaryBridge project it could be more
> suitable for his purpose, but afaik only Cowboy is full binary so
> far (only accepting (io)lists as output data). And of course adding
> Cowboy to SimpleBridge would just be a binary_to_list fest and would
> remove half the advantages of using that server so it's a bit of a
> dead end there.
>
>
> On 12/19/2011 10:16 PM, Andrew Berman wrote:
>
> There was talk on one of the mailing lists about using something
> like
> SimpleBridge (https://github.com/nitrogen/__simple_bridge
> <https://github.com/nitrogen/simple_bridge>) so that the use
> of a web server could be independent of Webmachine's logic,
> which IMO is
> the best solution. I don't think anyone did anything about it,
> but for
> some reason, SimpleBridge has Webmachine support, which doesn't make
> sense logically to me since Webmachine is a toolkit and not a
> web server.
>
> I use Webmachine and love what it does for me, but the code
> seems overly
> complicated with a heavy reliance on Mochiweb and uses parameterized
> modules (an unsupported feature of Erlang), so I would actually
> be more
> inclined to start a new project which is influenced by
> Webmachine but
> corrects all the issues with it and makes it a bit more flexible and
> modern (would love for Webmachine to support PATCH for example and
> something like Socket.IO). I'd be happy to help out with such a
> project
> if anyone is interested in starting one.
>
> --Andrew
>
> On Mon, Dec 19, 2011 at 12:24 PM, Tristan Sloughter
> <tristan.sloughter@REDACTED
> <mailto:tristan.sloughter@REDACTED>
> <mailto:tristan.sloughter@REDACTED
> <mailto:tristan.sloughter@REDACTED>>> wrote:
>
> Interesting. Sucks that webmachine is so tied to mochi and
> mochi so
> tied to lists, haha. But I'll give this a look.
>
> Tristan
>
>
> On Mon, Dec 19, 2011 at 1:50 PM, Magnus Klaar
> <magnus.klaar@REDACTED <mailto:magnus.klaar@REDACTED>
> <mailto:magnus.klaar@REDACTED
> <mailto:magnus.klaar@REDACTED>__>> wrote:
>
> Hi!
>
> Cowboy currently includes an experimental webmachine-like
> interface. The first commit of this module should
> explain some
> of the key differences from webmachine. If i remember the
> history of this module the intial estimate for the time
> needed
> to decouple webmachine from mochiweb _and_ refactor
> webmachine
> to support both binaries and lists everywhere was
> greater than
> the time needed to just add the difference between the
> two to
> cowboy.
>
> https://github.com/extend/__cowboy/commit/__aab1587a4b3d8f0c3d92a208322752__7d51109980
> <https://github.com/extend/cowboy/commit/aab1587a4b3d8f0c3d92a2083227527d51109980>
>
> If you're interested in a
>
> MVH Magnus
>
> On Mon, Dec 19, 2011 at 6:40 PM, Tristan Sloughter
> <tristan.sloughter@REDACTED <mailto:tristan.sloughter@REDACTED>
> <mailto:tristan.sloughter@REDACTED
> <mailto:tristan.sloughter@REDACTED>>> wrote:
>
> This may be better on a Webmachine questions list. But I
> thought I'd ask here first since it may be that someone
> working on one of the other Erlang web servers, besides
> Mochiweb, has worked on moving Webmachine to use
> that server.
>
> The reason I say that is, Webmachine currently relies on
> Mochiweb which passes lists instead of binary
> strings for
> requests. While the req_body of a request is given as a
> binary the path_info and query string is dealt with as
> lists. While I would think there could be a
> performance hit
> due to this my main reason to ask for alternatives
> is that
> dealing with JSON representations on the backend require
> converting the lists to binaries for processing
> every time.
>
> There has been
> https://github.com/mochi/__mochiweb/pull/38
> <https://github.com/mochi/mochiweb/pull/38> but
> its clear at the end of the discussion its not a
> change that
> will be happening to mochiweb anytime soon.
>
> So is there work on Webmachine backed by Cowboy or
> another
> Erlang web server?
>
> Thanks,
> Tristan
>
> _________________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> <mailto:erlang-questions@REDACTED
> <mailto:erlang-questions@REDACTED>>
>
> http://erlang.org/mailman/__listinfo/erlang-questions
> <http://erlang.org/mailman/listinfo/erlang-questions>
>
>
>
>
> _________________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> <mailto:erlang-questions@REDACTED
> <mailto:erlang-questions@REDACTED>>
>
> http://erlang.org/mailman/__listinfo/erlang-questions
> <http://erlang.org/mailman/listinfo/erlang-questions>
>
>
>
>
> _________________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> http://erlang.org/mailman/__listinfo/erlang-questions
> <http://erlang.org/mailman/listinfo/erlang-questions>
>
>
>
> --
> Loďc Hoguin
> Dev:Extend
>
>
--
Loïc Hoguin
Dev:Extend
More information about the erlang-questions
mailing list