diff options
author | Eric Wong <e@80x24.org> | 2016-07-02 07:56:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-07-02 07:57:27 +0000 |
commit | e358bd7a3833f8c5bf9db57d228888f9c5f3692e (patch) | |
tree | 4822b8d06e92f78ea3861d83f8c999015ccae397 /lib/PublicInbox/Inbox.pm | |
parent | 0f9091f381191484f1a5ed5189d23cbfa88de6fc (diff) | |
download | public-inbox-e358bd7a3833f8c5bf9db57d228888f9c5f3692e.tar.gz |
This is lighter and we can work further towards eliminating our Plack::Request dependency entirely.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r-- | lib/PublicInbox/Inbox.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index ada713c7..96c92652 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -71,10 +71,14 @@ sub cloneurl { } sub base_url { - my ($self, $prq) = @_; # Plack::Request - if (defined $prq) { - my $url = $prq->base->as_string; - $url .= '/' if $url !~ m!/\z!; # for mount in Plack::Builder + my ($self, $env) = @_; + if ($env) { # PSGI env + my $scheme = $env->{'psgi.url_scheme'}; + my $host_port = $env->{HTTP_HOST} || + "$env->{SERVER_NAME}:$env->{SERVER_PORT}"; + my $url = "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/'); + # for mount in Plack::Builder + $url .= '/' if $url !~ m!/\z!; $url .= $self->{name} . '/'; } else { # either called from a non-PSGI environment (e.g. NNTP/POP3) |