Skip to content

Instantly share code, notes, and snippets.

@shelling
Created July 26, 2012 13:43
Show Gist options
  • Select an option

  • Save shelling/3182094 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/3182094 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use AnyEvent::HTTPD;
my $httpd = AnyEvent::HTTPD->new(port => 3000);
use MogileFS::Client;
my $client = MogileFS::Client->new( domain => "test", hosts => ["localhost:7001"] );
use MIME::Types;
my $mime = MIME::Types->new;
my $moghandler = sub {
my ($httpd, $req) = @_;
my $body = $client->get_file_data($req->url);
$req->respond({
content => [$mime->mimeTypeOf($req->url), $$body]
});
};
$httpd->reg_cb( "" => $moghandler );
$httpd->run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment