Skip to content
Kelly McLaughlin edited this page Apr 26, 2013 · 9 revisions

A Webmachine instance configuration is comprised of a list of erlang tuples. This syntax may seem strange to those not familiar with Erlang, but it is relatively simple and the following information should help.

Configuration Options

IP address adnd port number

The Webmachine instance accepts connections on the IP address specified by the ip tuple in the configuration and listens on the port number specified by the port tuple. The IP address should be a string and the port number must be a valid integer.

{ip, "192.168.1.1"},
{port, 8080},

SSL

TCP options

nodelay

Dispatch groups

Error handler

URL rewriting

As of 1.10.0, Webmachine features the ability to rewrite incoming URLs and headers based on a set of rules. These rules can be defined in an Erlang module and the module name specified as part of the configuration. More details about it can be found here.

The rules module can be specified in the configuration as follows:

{rewrite_module, my_rewrite_rules_mod},

Resource module option

[{dispatch, riak_cs_web:object_api_dispatch_table()},
 {name, object_web},
 {dispatch_group, object_web},
 {ip, proplists:get_value(cs_ip, Options)},
 {port, proplists:get_value(cs_port, Options)},
 {nodelay, true},
 {rewrite_module, riak_cs_s3_rewrite},
 {error_handler, riak_cs_wm_error_handler},
 {resource_module_option, submodule}] ++
    maybe_add_ssl_opts(proplists:get_value(ssl, Options)).

Creating the supervisor spec

Once the desired configuration options have been selected, the next step is to create a child spec to give to an erlang supervisor process. An example would be:

{wm_instance_1,
    {webmachine_mochiweb, start, [Config]},
        permanent, 5000, worker, dynamic}.

wm_instance_1 serves as an identifier used by the erlang supervisor process. It may be changed. If using more than once instance of webmachine in an application, each instance must use a unique identifier.

Clone this wiki locally