anotherjesse (owner)

Revisions

gist: 212921 Download_button fork
public
Public Clone URL: git://gist.github.com/212921.git
Embed All Files: show embed
s3.erl #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
% experimenting with erlang (using misultin) to build a crappy S3-like service
 
-module(s3).
-export([start/1, stop/0, handle_http/1]).
 
start(Port) ->
    misultin:start_link([{port, Port}, {loop, fun(Req) -> handle_http(Req) end}]).
 
stop() ->
    misultin:stop().
 
handle_http(Req) ->
    {abs_path, Path} = Req:get(uri),
    io:format("req: ~p~n", [Path]),
    case file:read_file_info(Path) of
        {ok, FileInfo} ->
            Req:file(Path);
        _ ->
            Req:ok("missing")
    end.