Last active
December 23, 2015 08:09
-
-
Save worr/6605541 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cravatar; | |
use Dancer ':syntax'; | |
use Dancer::Plugin::LDAP; | |
use Dancer::Plugin::Cache::CHI; | |
use Net::LDAP::Util qw/escape_filter_value/; | |
use Try::Tiny; | |
our $VERSION = '0.1'; | |
check_page_cache; | |
get '/:UUID.jpg' => sub { | |
my $uuid = param 'UUID'; | |
my $ret; | |
try { | |
$ret = [ (ldap->search( | |
base => "ou=Users,dc=csh,dc=rit,dc=edu", | |
filter => "entryUUID=".escape_filter_value($uuid), | |
attrs => [ 'jpegPhoto' ], | |
)->entries()) ]->[0]->get('jpegPhoto'); | |
} or status 404; | |
my $photo = $ret->[0]; | |
cache_page send_file(\$photo, content_type => 'image/jpeg'); | |
}; | |
true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment