Skip to content
/ leptus Public
forked from sinasamavati/leptus

Erlang REST framework that runs on top of cowboy

License

Notifications You must be signed in to change notification settings

Ledest/leptus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leptus https://travis-ci.org/Ledest/leptus.png

Leptus is an Erlang REST framework that runs on top of cowboy.

Leptus aims at simply creating RESTful APIs.

Requirements

Installation

Clone it and just run make

OR

If you want to use it as a dependency in your project add the following to your rebar configuration

{deps, [
        ...
        {leptus, ".*", {git, "git://github.com/s1n4/leptus.git", {branch, "master"}}}
       ]}.

Quick example

-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 = leptus_req:param(Req, name),
    Body = [{<<"say">>, <<"Hi">>}, {<<"to">>, Name}],
    {Status, {json, 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"}

Features

  • Supports GET, PUT, POST and DELETE HTTP methods
  • Can respond in plain text, JSON or MessagePack
  • 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

Check out the docs directory.

Support

License

MIT, see LICENSE file for more details.

About

Erlang REST framework that runs on top of cowboy

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 96.6%
  • Makefile 3.4%