perlancar > Web-Detect > Web::Detect

Download:
Web-Detect-0.05.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.05   Source  

NAME ^

Web::Detect - Detect if program is running under some web environment

VERSION ^

This document describes version 0.05 of Web::Detect (from Perl distribution Web-Detect), released on 2015-01-03.

SYNOPSIS ^

    use Web::Detect qw(detect_web detect_web_fast);
    use IO::Interactive::Tiny ();

    if (Web::Detect::detect_web_fast()) {
        # do HTML
    }
    else {
        # do CLI
        if (IO::Interactive::Tiny::is_interactive()) {
            # prompt/ANSI/etc
        }
        else {
            # do not prompt/plain text/etc
        }
    }

DESCRIPTION ^

Knowing if you are under a web environment or not is very handy.

For example, often you need to decide whether to output HTML or plaintext.

FUNCTIONS ^

Functions are exportable but are not exported by default.

detect_web() => HASHREF

Return false if not detected running under any web environment.

Return a hash otherwise.

These keys exists if it is detected that we are running under the given environment and the value is suitable as a boolean (always true).

mod_perl
plack
pangea
cpanel

http://cpanel.net

catalyst
dancer
mojo
FCGI.pm
IIS
cgi

General CGI

general

Value can be 1 if it was detected during the first general check, 2 if it was detected during the second general check, and 3 if it was detected under both.

Additionally, psgi is also true if we know its a PSGI environment.

detect_web_fast()

Same as detect_web() but return HASHREF upon first successful check instead of trying all heuristics.

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Web-Detect.

SOURCE ^

Source repository is at https://github.com/sharyanto/perl-Web-Detect.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Web-Detect

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: