Skip to content
LFE OTP Cowboy server seed project
LFE Erlang Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
include
src
test
.gitignore
LICENSE
README.md
build
clean
lfe-mnesia
lfe.config
rebar.config
repl

README.md

dnet

A seed project for server based on LFE OTP, Cowboy, Mnesia with build and dependency management using rebar3. The project demonstrates the use of LFE with OTP gen_server with different type of supervisors. Cowboy is used for the web server and Cowboy Gun is used as the HTTP client. The HTML is generated using Exemplar.

Run

  1. Build the project.
./build
  1. Start the Erlang shell and then start LFE REPL.
./repl
1> lfe_shell:server().
  1. Start the OTP application.
lfe> (dnet:start)
#(ok (cowlib ranch cowboy gun dnet))

APIs

A GET request which returns JSON.

λ curl -X GET "http://localhost:8080/"
{"status": "main"}% 

A POST request which returns HTML. The given resource is fetched using Gun and the response stream is handled asynchronously.

λ curl -X POST \
  'http://localhost:8080/http' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://jsonip.com/"
}
'
<div>Task scheduled successfully</div>% 

Supervisors

               ┌──────┐
          ┌───▶│db-sup│
          │    └──────┘
          │
┌────┐    │    ┌────────────┐
│dnet│────┼───▶│dnet-svc-sup│
└────┘    │    └────────────┘
          │
          │    ┌────────┐
          └───▶│http-sup│
               └────────┘
You can’t perform that action at this time.