[SP-pm] Mojolicious Daemon e Client em JSON
Ricardo Stock
ricardostock at bol.com.br
Thu Sep 20 04:00:35 PDT 2012
Pegando o bonde andando....
Mem desculpe, para pegar o ip do cliente, não pode ser feito assim ?
my $ip_cliente=$ENV{REMOTE_ADDR};
Ricardo Stock
www.stocksistemas.com.br
----- Original Message -----
From: Solli Honorio
To: saopaulo-pm em mail.pm.org
Sent: Wednesday, September 19, 2012 9:49 PM
Subject: Re: [SP-pm] Mojolicious Daemon e Client em JSON
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
------------------------------------------------------------------------------
=begin disclaimer
Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
SaoPaulo-pm mailing list: SaoPaulo-pm em pm.org
L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
=end disclaimer
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20120920/0f0347f6/attachment.html>
More information about the SaoPaulo-pm
mailing list