Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sinasamavati/leptus
The Erlang REST framework
https://github.com/sinasamavati/leptus
erlang rest web
Last synced: 1 day ago
JSON representation
The Erlang REST framework
- Host: GitHub
- URL: https://github.com/sinasamavati/leptus
- Owner: sinasamavati
- License: mit
- Created: 2013-09-18T18:47:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-05-13T15:13:36.000Z (over 3 years ago)
- Last Synced: 2024-07-29T22:13:26.599Z (6 months ago)
- Topics: erlang, rest, web
- Language: Erlang
- Homepage: https://sinasamavati.com/leptus
- Size: 684 KB
- Stars: 346
- Watchers: 21
- Forks: 50
- Open Issues: 5
-
Metadata Files:
- Readme: README.org
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
* Leptus
Leptus is an Erlang REST framework that runs on top of Cowboy web server.
Leptus simplifies creating RESTful APIs in Erlang.
** Requirements
- Erlang/OTP 18 or newer
- [[https://github.com/ninenines/cowboy][Cowboy 2.4.0]]
- [[https://github.com/davisp/jiffy][Jiffy 0.15.2]]** Installation
Clone it, and run ~make~. Or add it to your rebar configuration.
#+BEGIN_SRC erlang
{deps, [
{leptus, ".*", {git, "git://github.com/sinasamavati/leptus.git", {branch, "master"}}}
]}.
#+END_SRC** Quick Example
#+BEGIN_SRC erlang
-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.
#+END_SRC#+BEGIN_SRC
$ erl -pa ebin deps/*/ebin
#+END_SRC#+BEGIN_SRC erlang
1> c(hello).
2> leptus:start_listener(http, [{'_', [{hello, undefined_state}]}]).
Leptus started on http://127.0.0.1:8080
#+END_SRC#+BEGIN_SRC
$ curl localhost:8080/hi/Leptus
{"say":"Hi","to":"Leptus"}
#+END_SRC** Features
- Supports ~GET~, ~PUT~, ~POST~ and ~DELETE~ 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** Documentation
Please refer to [[https://sinasamavati.com/leptus][https://sinasamavati.com/leptus]].
** Support
- [[https://github.com/sinasamavati/leptus/issues][Issue tracker]]
- #leptus IRC channel on Freenode
- [[https://groups.google.com/group/leptus][leptus]] mailing-list on Google Groups** License
MIT, see LICENSE file for more details.