Leptus is an Erlang REST framework that runs on top of Cowboy web server.
Leptus simplifies creating RESTful APIs in Erlang.
- Erlang/OTP 18 or newer
- Cowboy 2.4.0
- Jiffy 0.15.2
Clone it, and run make
. Or add it to your rebar configuration.
{deps, [
{leptus, ".*", {git, "git://github.com/sinasamavati/leptus.git", {branch, "master"}}}
]}.
-module(hello).
-compile({parse_transform, leptus_pt}).
%% leptus callbacks
-export([init/3]).
-export([get/3]).
-export([terminate/4]).
init(_Route, _Req, State) ->
{ok, State}.
get("/", _Req, State) ->
{<<"Hello, leptus!">>, State};
get("/hi/:name", Req, State) ->
Status = ok,
Name = cowboy_req:binding(name, Req),
Body = #{<<"say">> => <<"Hi">>, <<"to">> => Name},
{Status, Body, State}.
terminate(_Reason, _Route, _Req, _State) ->
ok.
$ erl -pa ebin deps/*/ebin
1> c(hello).
2> leptus:start_listener(http, [{'_', [{hello, undefined_state}]}]).
Leptus started on http://127.0.0.1:8080
$ curl localhost:8080/hi/Leptus {"say":"Hi","to":"Leptus"}
- Supports
GET
,PUT
,POST
andDELETE
HTTP methods - Can respond in plain text or JSON
- Supports basic authentication
- Can be upgraded while it’s running (no stopping is required)
- Supports HTTPS
- Provides a simple way for dealing with Cross-Origin Resource Sharing
Please refer to https://sinasamavati.com/leptus.
- Issue tracker
- #leptus IRC channel on Freenode
- leptus mailing-list on Google Groups
MIT, see LICENSE file for more details.