[erlang-questions] Webmachine questions -- WAS Re: Help wanted: very specific web server that perhaps doesn't have to be a web server

Ivan Uemlianin ivan@REDACTED
Mon Nov 28 15:13:09 CET 2011


Dear All

Thanks for your suggestions.

I've decided to stick with mochiweb for this one.

However, I had a good read of the webmachine documentation, and I think 
I've got an idea for how I could use it.  If you don't mind I'd like to 
run it past people here before I take it further.

Last year I wrote a translation server.  Each translator was a running 
Moses instance.  You would send GET requests to the server asking for 
translations from particular translators (all the translators were 
Welsh-English, but each had a special subject: weather, sport, etc.).

It was a handy little server (written in python), but it was kind of ad 
hoc and incomplete (e.g., updating and creating new translators had to 
be done separately), and unsatisfying.

A translation server with a more principled and comprehensive http api 
is an attractive prospect.

Would I overload the http methods like this:?

   GET   ask for a translation from a particular translator
   POST  submit new translation pair to a particular translator
   OPTIONS  find out what translators are available, or find out 
properties of a particular translator
   PUT   create a new translator
   PATCH create an updated version of an existing translator

I'm used to couching web app apis in terms of GET and POST.  Will using 
other method types preclude using a web browser as a client?

If this sounds sensible I'll write up the interface, work backwards from 
that to the webmachine resource functions, and from that to the erlang 
interface to Moses.

With thanks and best wishes

Ivan


On 17/11/11 17:04, Alex Shneyderman wrote:
> it is a bit confusing to find the docs on webmachine (at least it was for me)
> http://wiki.basho.com/Webmachine.html
> Should get you there. All the stuff and more (debug/tracing) is there.
> Very simple to start. I am surely impressed :-)
>
> On Thu, Nov 17, 2011 at 5:57 PM, Ivan Uemlianin<ivan@REDACTED>  wrote:
>> Dear Max
>>
>> Thanks for your suggestion.
>>
>> Webmachine is a good candidate.  I'll try it out.
>>
>> Best wishes
>>
>> Ivan
>>
>>
>> On 17/11/2011 14:19, Max Bourinov wrote:
>>>
>>> Hi Ivan,
>>>
>>> For the same purpose we use webmachine (mochiweb is a part of it) as it
>>> runs very well.
>>>
>>> Why don't you like this approach? It solves many potential problems you
>>> may face.
>>>
>>> Best regards,
>>> Max
>>>
>>>
>>>
>>>
>>> On Thu, Nov 17, 2011 at 4:39 PM, Ivan Uemlianin<ivan@REDACTED
>>> <mailto:ivan@REDACTED>>  wrote:
>>>
>>>     Dear All
>>>
>>>     Sorry for the verbose subject line.
>>>
>>>     I'm working on a social-networking web application, part of which is
>>>     written in erlang (it's part django and part erlang, with nginx in
>>>     front).  I'm refactoring the erlang to give it a better OTP
>>>     application structure.  It'll break down something like this:
>>>
>>>     - webserver (currently mochiweb)
>>>     - datastore for "state"
>>>     - datastore for "archive"
>>>
>>>     Now, there's a single GET request url that I'd like to run in a
>>>     separate application.  The service that this url provides is
>>>     completely separate (e.g., could exist on its own; we'd want it to
>>>     fail separately; provides service to other webapps).  So:
>>>
>>>     - general webserver (currently mochiweb)
>>>     - datastore for "state"
>>>     - datastore for "archive"
>>>     - thing for special web service
>>>
>>>     The special web service responds to GET requests to a particular
>>>     url. The path and parameters are always the same.  Like this:
>>>
>>>     http://eg.com/special_service/__?a=this&b=that&c=other
>>>     <http://eg.com/special_service/?a=this&b=that&c=other>
>>>
>>>     Nginx will catch these requests and send them to the thing, and I
>>>     have an erlang function that processes the parameters and returns a
>>>     result. All I need is something that will (a) take the parameters
>>>     from the request and give them to the function, and (b) take the
>>>     function results, wrap them in an http response and send them back
>>>     to nginx.
>>>
>>>     This thing for special web service could easily be Mochiweb (and
>>>     that's what I'll be working with for now).  I wondered if there
>>>     might be something simpler (inets?) which more narrowly fits my
>>>     minimal requirements (this might be partly an nginx question --- can
>>>     nginx pass on GET parameters to a running process and return the
>>>     result to the original requester?  I'll be looking into that too).
>>>
>>>     Sorry if this is too hand-wavy for sensible answers.
>>>
>>>     With thanks and best wishes
>>>
>>>     Ivan
>>>
>>>
>>>     --
>>>     ==============================__==============================
>>>     Ivan A. Uemlianin
>>>     Speech Technology Research and Development
>>>
>>>     ivan@REDACTED<mailto:ivan@REDACTED>
>>>     www.llaisdy.com<http://www.llaisdy.com>
>>>     llaisdy.wordpress.com<http://llaisdy.wordpress.com>
>>>     www.linkedin.com/in/__ivanuemlianin
>>>     <http://www.linkedin.com/in/ivanuemlianin>
>>>
>>>     "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
>>>                          (Schiller, Beethoven)
>>>     ==============================__==============================
>>>     _________________________________________________
>>>     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>
>>>
>>>
>>
>>
>> --
>> ============================================================
>> Ivan A. Uemlianin
>> Speech Technology Research and Development
>>
>>                     ivan@REDACTED
>>                      www.llaisdy.com
>>                          llaisdy.wordpress.com
>>                      www.linkedin.com/in/ivanuemlianin
>>
>>     "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
>>                      (Schiller, Beethoven)
>> ============================================================
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>


-- 
============================================================
Ivan A. Uemlianin
Speech Technology Research and Development

                     ivan@REDACTED
                      www.llaisdy.com
                          llaisdy.wordpress.com
                      www.linkedin.com/in/ivanuemlianin

     "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
                      (Schiller, Beethoven)
============================================================



More information about the erlang-questions mailing list