Questions tagged [webmachine]

WebMachine is an Erlang framework for creating RESTful Web Services using Erlang/OTP best practices.

Webmachine is an application layer that adds HTTP semantic awareness on top of the excellent bit-pushing and HTTP syntax-management provided by mochiweb, and provides a simple and clean way to connect that to your application's behavior.

A Webmachine application is a set of resources, each of which is a set of functions over the state of the resource. We really mean functions here, not object-methods, infinite-server-loops, or any other such construction. This aspect of Webmachine is one of the reasons why Webmachine applications are relatively easy to understand and extend.

These functions give you a place to define the representations and other Web-relevant properties of your application's resources -- with the emphasis that the first-class things on the Web are resources and that their essential properties of interaction are already quite well defined and usefully constrained.

For most Webmachine applications, most of the functions are quite small and isolated. One of the nice effects of this is that a quick reading of a resource will give you an understanding of the application, its Web behavior, and the relationship between them. Since these functions are usually referentially transparent, Webmachine applications can be quite easy to test. There's no need for mock objects, fake database connections, or any other wastes of time when you can write tests against each component of your application in terms of the input and output to various functions.

We believe that by giving Web developers a system with conventions that directly map to HTTP and REST, we help them to write and extend Web applications quickly while not dictating the shape of the rest of their application. The resulting applications are straightforward to examine and maintain, and have very easily understood HTTP semantics. It is also available for ruby as webmachine-ruby

36 questions
1
vote
2 answers

Webmachine dispatch.conf: how to bind to /

I am working on a hello world webmachine application. What I want is that all requests are mapped to blogtest_resource except if it starts with "static". In this case, it is mapped to static_resource. {["static", '*'], static_resource, [{root,…
tamasd
  • 5,747
  • 3
  • 25
  • 31
1
vote
1 answer

Webmachine: Who sets static_resource:init/1?

I'm looking at two versions static_resource:init/1 in two Webmachine applications: https://github.com/basho/wriaki/blob/master/apps/wriaki/src/session_resource.erl http://lambder.com/2009/06/providing-static-content-in-webmachine/ In both cases the…
Lloyd R. Prentice
  • 4,329
  • 3
  • 21
  • 31
1
vote
3 answers

How to pattern match structures returned by mochijson2?

I've just started tinkering with Erlang and am building a very simple test web application which is just intended to show my twitter timeline. I'm using webmachine to write the app and erlyDTL to render the templates. My question is related to the…
peeb
  • 11
  • 2
1
vote
1 answer

(Multipart) zip upload in ruby webmachine handled by rack

I'm making an upload form for zips in a ruby webmachine app. My idea is to have an upload through my backend where I can add some extra params and then upload it to amazons s3 service with RestClient. I did successfully create a direct upload (web…
LiveNL
  • 194
  • 2
  • 15
1
vote
1 answer

Erlang/Webmachine doesn't start on heroku

I've been trying to setup a Webmachine app on Heroku, using the buildpack recommended. My Procfile is # Procfile web: sh ./rel/app_name/bin/app_name console Unfortunately this doesn't start the dyno correctly, it fails…
Máté
  • 2,294
  • 3
  • 18
  • 25
1
vote
0 answers

REST for Yaws: roll one's own solution or use Yaws + Webmachine?

I was reading a couple of articles on how to use Yaws in a RESTful way, how Webmachine maps HTTP semantics to resources and all of them helped a lot to grasp the concept. Example API in Zack Kessin's Building Web Applications with Erlang Steve…
toraritte
  • 6,300
  • 3
  • 46
  • 67
1
vote
1 answer

Webmachine on different machines

I have a webmachine REST API server running on one machine. in anticipation of having more traffic that this machine cannot handle, i would need to expand to other nodes on other cpu`s. is there a way of configuring this? if not what is the right…
user2840420
1
vote
1 answer

What is a good way to keep https client running in an erlang webmachine server application?

In a webmachine project I am also requesting https pages from other servers. In the prototype I managed to do it in this way: to_html(ReqData, State) -> OtherResource = "https://example.com", inets:start(), ssl:start(), {ok,…
SHernandez
  • 1,060
  • 1
  • 14
  • 21
0
votes
1 answer

Webmachine: How can I retrieve multiple values from URL via wrq:get_qs_value?

I get this: T = wrq:get_qs_value("name",ReqData) But suppose I want to retrieve "fname", "lname", "gnder", "age", etc. from a form submission. Do I need to repeat variations on the line above for every variable? Or is there a more elegant…
Lloyd R. Prentice
  • 4,329
  • 3
  • 21
  • 31
0
votes
1 answer

How to accept a PUT multipart file in webmachine-ruby

I am trying to upload a file to a webmachine resource using PUT. The idea is to update the template resource with a file_id. module App::Resources class UpdateTemplateResource < TemplateResource def allowed_methods %W(PUT) end …
gmuraleekrishna
  • 3,375
  • 1
  • 27
  • 45
0
votes
1 answer

Webmachine {not_started,mochiweb}

I'm new to Erlang's Webmachine, and I'm having a bit of trouble even getting a basic "hello world" going. Whenever I run ./start.sh, I get a big error like this: ➜ webmachine git:(master) ./start.sh Erlang/OTP 17 [erts-6.3.1] [source] [64-bit]…
Tombert
  • 530
  • 5
  • 13
0
votes
0 answers

Nitrogen wf.hrl file is deleted with a warning

I am using a slim_version of cowboy, I have also tried that on slim_yaws on nitrogen. What puzzles me is the abrupt deletion of the wf.hrl file by the VM. I do not understand what causes this!! Here is what appears in the console. Warning. Deleted…
0
votes
1 answer

Error setting up Webmachine

I'm on OS X 10.10.1 and I have Erlang installed. Namely: Erlang/OTP 17 [erts-6.2.1] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] I would like to follow one of the many webmachine introductory tutorials, and…
pkluz
  • 4,871
  • 4
  • 26
  • 40
0
votes
1 answer

Webmachine embedded?

Is there a way to run (the Erlang version of) Webmachine in an "embedded?" I want to embed the web app in an application I am writing. The web app will just be a front end communicating with a back end I am writing. I want everything (webmachine,…
user3355020
  • 315
  • 1
  • 9
0
votes
1 answer

How would I start more than one instance of webmachine in an erlang application?

I'm trying to create two instances of webmachine in one erlang application. Each instance is to run on a different port and has its own specific configuration. Following the webmachine doc here, I have added the following processes to be started…
xjrs
  • 3
  • 2