leptus
1.0.0
Leptus เป็นเฟรมเวิร์ก Erlang Rest ที่ทำงานบนเว็บเซิร์ฟเวอร์คาวบอย
Leptus ทำให้การสร้าง APIs ที่เงียบสงบง่ายขึ้นใน Erlang
โคลนมันแล้วเรียก make หรือเพิ่มลงในการกำหนดค่าเหล็กเส้นของคุณ
{ 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
{"พูด": "สวัสดี", "ถึง": "leptus"}
GET PUT POST และ DELETE วิธี HTTPโปรดดูที่ https://sinasamavati.com/leptus
MIT ดูไฟล์ใบอนุญาตสำหรับรายละเอียดเพิ่มเติม