Compiling and running Yaws applications

Appmods is a way to let an application programmer control the URL path. They are implemented as Erlang modules. For example, myappmod.erl

-module(myappmod).
-include("../../yaws_api.hrl").
-compile(export_all).

out(Arg) ->
    Method = (Arg#arg.req)#http_request.method,
    handle(Method, Arg).

handle(Method,Arg) ->
    %%  Do something 
    ok.

How do I compile to make this application easy to manage?

In which directory of the yaws directory tree should I save myappmod.erl and where does myappmod.beam go after compilation?

How to create a URL to link to this application?

All help is appreciated!

+3
source share
1 answer

- erlc . , Yaws, yaws.conf ebin_dir:

ebin_dir = /path/to/some/ebin
ebin_dir = /path/to/another/ebin

. ebin_dir — Yaws.

- sync.

URL- appmod yaws.conf, server, appmods. Yaws. , , appmod URL- , / URL-:

<server foo>
    port = 8001
    listen = 0.0.0.0
    docroot = /filesystem/path/to/www
    appmods = </, myappmod>
</server>

exclude_paths, appmods, . , , myappmod URL /, URL, /icons:

appmods = </, myappmod exclude_paths icons>
+3

Source: https://habr.com/ru/post/1611727/


All Articles