[SP-pm] Mojolicious Daemon e Client em JSON
Solli Honorio
shonorio at gmail.com
Wed Sep 19 17:49:09 PDT 2012
Nilson,
Você pode pegar o ip do cliente através de $self->tx->remote_address, como
no exemplo abaixo :
use Mojolicious::Lite;
# "whois" helper
helper whois => sub {
my $self = shift;
my $agent = $self->req->headers->user_agent || 'Anonymous';
my $ip = $self->tx->remote_address;
return "$agent ($ip)";
};
# /secret
get '/secret' => sub {
my $self = shift;
my $user = $self->whois;
$self->app->log->debug("Request from $user.");
};
app->start;
__DATA__
@@ secret.html.ep
We know who you are <%= whois %>.
Em 12 de setembro de 2012 22:23, Jose Nilton <jniltinho em gmail.com> escreveu:
> Nelson, obrigado
>
> Desculpe só responder o e-mail agora, tive uns contratempos de infra aqui
>
--
"o animal satisfeito dorme". - Guimarães Rosa
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20120919/7ac23f7b/attachment.html>
More information about the SaoPaulo-pm
mailing list