How can I integrate Webmachine into an Erlang Application?
I read and re-read the docs and tutorials, but my understanding of how to create Erlang Applications, and Rebar for that matter, still has enough holes to resemble Swiss cheese. Very simple stuff throws me.
I'm working toward an Erlang Release that will eventually include several applications of my own plus Webmachine and maybe a nosql db of one flavor or another. Using Rebar I've successfully compiled and tested my applications: ZZZ and ZZZ_Lib. my directory structure is shown below. I'm not confident that it's optimal, but it works.
I've installed Webmachine under the ...learn1/apps directory.
My next step has been to integrate Webmachine with the very simple webmachine_demo_resource shown below under the name test_resource:erl.
http://webmachine.basho.com/example_resources.html
But when I try to compile, I get this error message:
src/test_resource.erl:3: can't find include lib "webmachine/include/webmachine.hrl"
Here's the offending line in test_resource.erl:
-include_lib("webmachine/include/webmachine.hrl").
I've tried to set both ERL_LIBS (which I don't fully understand) and PATH with no success. So, clear开发者_JAVA技巧ly, I don't understand how to set the proper path or how best to integrate Webmachine.
Any and all guidance would be gratefully welcomed.
LRP
* Directory structure
learn1$ ls apps rebar rebar.config
learn1/apps$ ls webmachine zzz zzz_lib
learn1/apps/zzz_lib/src$ ls yada yada test_resource.erl yada yada
* rebar.config
{sub_dirs,
["apps/zzz",
"apps/zzz/src",
"apps/zzz_lib",
"apps/zzz_lib/src"
]
}.
* zzz_lib.app.src
{application, zzz_lib,
[
{description, ""},
{vsn, "1"},
{modules, [
yada yada
]},
{applications, [
kernel,
stdlib,
webmachine
]},
{mod, { zzz_lib_app, []}},
{env, []}
]}.
You most likely will end up happier including it as a dependency, not as a contained app. See for example how Riak Core does it: https://github.com/basho/riak_core/blob/master/rebar.config
For more insight, you might find asking the mailing lists to be worthwhile:
http://lists.therestfulway.com/mailman/listinfo/webmachine_lists.therestfulway.com
http://lists.basho.com/mailman/listinfo/rebar_lists.basho.com
Using ERL_LIBS
in your case, you'd need to set it to /.../learn1/apps
.
When compiling, you may also add a {i, Dir} option. According to the documentation however, it only mentions -include and -include_dir, not -include_lib.
{i,Dir} Add Dir to the list of directories to be searched when including a file. When encountering an -include or -include_dir directive, the compiler searches for header files in the following directories:
".", the current working directory of the file server;
the base name of the compiled file;
the directories specified using the i option. The directory specified last is searched first.
精彩评论