Skip to content

Instantly share code, notes, and snippets.

@anotherjesse
Created October 18, 2009 22:56
Show Gist options
  • Select an option

  • Save anotherjesse/212921 to your computer and use it in GitHub Desktop.

Select an option

Save anotherjesse/212921 to your computer and use it in GitHub Desktop.
% 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment