tsujigiri/axiom

Correct way of running Axiom application as a OTP application

piotr-sobczyk opened this issue · 1 comments

How can I convert "hello world' application from "Getting started" section to OTP project that is generated by rebar?

When I create invoke rebar create-app I end up with some skeleton files in src directory, like myapp.app.src, myapp_app.erl and myapp_sup.erl. Where is the correct place to add axiom code. Should "Hello world" application be implemented inside myapp_app.erl, like:

...

%% ===================================================================
%% Application callbacks
%% ===================================================================

start(_StartType, _StartArgs) ->
    myapp_sup:start_link(),
    axiom:start(?MODULE).

handle(<<"GET">>, [<<"hi">>], _Request) ->
    <<"Hello world!">>.

Is this the correct place? If not, what's the correct place to add axiom code and how to invoke it?

How to run my application in this approach? It was extremely hard for my to find so easy examples in web :/.

There is a minimal example app:
https://github.com/tsujigiri/axiom_example

Does this help?