{
    "content": [
        {
            "type": "text",
            "text": "# Net::Server::PSGI (perldoc)\n\n## NAME\n\nNet::Server::PSGI - basic Net::Server based PSGI HTTP server class\n\n## SYNOPSIS\n\nuse base qw(Net::Server::PSGI);\nPACKAGE->run(app => \\&myechohandler); # will bind IPv4 port 80\nsub myechohandler {\nmy $env = shift;\nmy $txt = qq{<form method=\"post\" action=\"/bam\"><input type=\"text\" name=\"foo\"><input type=\"submit\"></form>\\n};\nrequire Data::Dumper;\nlocal $Data::Dumper::Sortkeys = 1;\nrequire CGI::PSGI;\nmy $form = {};\nmy $q = CGI::PSGI->new($env);\n$form->{$} = $q->param($) for $q->param;\n$txt .= \"<pre>\".Data::Dumper->Dump([$env, $form], ['env', 'form']).\"</pre>\";\nreturn [200, ['Content-type', 'text/html'], [$txt]];\n}\n\n## DESCRIPTION\n\nIf you want a more fully featured PSGI experience, it would be wise to look at the Plack and\nStarman set of modules. Net::Server::PSGI is intended as an easy gateway into PSGI. But to get\nthe most out of all that PSGI has to offer, you should review the Plack and Plack::Middleware.\nIf you only need something a little more rudimentary, then Net::Server::PSGI may be good for\nyou.\n\n## Sections\n\n- **NAME**\n- **TEST ONE LINER**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **OPTIONS**\n- **AUTHOR**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Net::Server::PSGI",
        "section": "",
        "mode": "perldoc",
        "summary": "Net::Server::PSGI - basic Net::Server based PSGI HTTP server class",
        "synopsis": "use base qw(Net::Server::PSGI);\nPACKAGE->run(app => \\&myechohandler); # will bind IPv4 port 80\nsub myechohandler {\nmy $env = shift;\nmy $txt = qq{<form method=\"post\" action=\"/bam\"><input type=\"text\" name=\"foo\"><input type=\"submit\"></form>\\n};\nrequire Data::Dumper;\nlocal $Data::Dumper::Sortkeys = 1;\nrequire CGI::PSGI;\nmy $form = {};\nmy $q = CGI::PSGI->new($env);\n$form->{$} = $q->param($) for $q->param;\n$txt .= \"<pre>\".Data::Dumper->Dump([$env, $form], ['env', 'form']).\"</pre>\";\nreturn [200, ['Content-type', 'text/html'], [$txt]];\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "TEST ONE LINER",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 62,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Net::Server::PSGI - basic Net::Server based PSGI HTTP server class\n",
                "subsections": []
            },
            "TEST ONE LINER": {
                "content": "perl -e 'use base qw(Net::Server::PSGI); main->run(port => 8080, ipv => \"*\")'\n# runs a default echo server\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use base qw(Net::Server::PSGI);\nPACKAGE->run(app => \\&myechohandler); # will bind IPv4 port 80\n\nsub myechohandler {\nmy $env = shift;\nmy $txt = qq{<form method=\"post\" action=\"/bam\"><input type=\"text\" name=\"foo\"><input type=\"submit\"></form>\\n};\n\nrequire Data::Dumper;\nlocal $Data::Dumper::Sortkeys = 1;\n\nrequire CGI::PSGI;\nmy $form = {};\nmy $q = CGI::PSGI->new($env);\n$form->{$} = $q->param($) for $q->param;\n\n$txt .= \"<pre>\".Data::Dumper->Dump([$env, $form], ['env', 'form']).\"</pre>\";\n\nreturn [200, ['Content-type', 'text/html'], [$txt]];\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "If you want a more fully featured PSGI experience, it would be wise to look at the Plack and\nStarman set of modules. Net::Server::PSGI is intended as an easy gateway into PSGI. But to get\nthe most out of all that PSGI has to offer, you should review the Plack and Plack::Middleware.\nIf you only need something a little more rudimentary, then Net::Server::PSGI may be good for\nyou.\n\nNet::Server::PSGI takes Net::Server::HTTP one level farther. It begins with base type MultiType\ndefaulting to Net::Server::Fork. It is easy to change it to any of the other Net::Server flavors\nby passing servertype => $otherflavor in the server configuration. The port has also been\ndefaulted to port 80 - but could easily be changed to another through the server configuration.\nYou can also very easily add ssl by including, proto=>\"ssl\" and provide a SSLcertfile and\nSSLkeyfile.\n\nFor example, here is a basic server that will bind to all interfaces, will speak both HTTP on\nport 8080 as well as HTTPS on 8443, and will speak both IPv4, as well as IPv6 if it is\navailable.\n\nuse base qw(Net::Server::PSGI);\n\nPACKAGE->run(\nport  => [8080, \"8443/ssl\"],\nipv   => '*', # IPv6 if available\nSSLkeyfile  => '/my/key',\nSSLcertfile => '/my/cert',\n);\n",
                "subsections": []
            },
            "METHODS": {
                "content": "\"processrequest\"\nThis method has been overridden in Net::Server::PSGI - you should not use it while using\nNet::Server::PSGI. This overridden method parses the environment and sets up request alarms\nand handles dying failures. It calls processpsgirequest once the request is ready and\nheaders have been parsed.\n\n\"processpsgirequest\"\nUsed when psgienabled is true. During this method, findpsgihandler will be called to\nreturn the appropriate psgi response handler. Once finished, printpsgiheaders and\nprintpsgibody are used to print out the response. See PSGI.\n\nTypically this method should not be overridden. Instead, an appropriate method for finding\nthe app should be given to findpsgihandler or app.\n\n\"findpsgihandler\"\nUsed to lookup the appropriate PSGI handler. A reference to the already parsed $env hashref\nis passed. PATHINFO will be initialized to the full path portion of the URI. SCRIPTNAME\nwill be initialized to the empty string. This handler should set the appropriate values for\nSCRIPTNAME and PATHINFO depending upon the path matched. A code reference for the handler\nshould be returned. The default findpsgihandler will call the \"app\" method. If that fails\na reference to the psgiechohandler is returned as the default application.\n\nsub findpsgihandler {\nmy ($self, $env) = @;\n\nif ($env->{'PATHINFO'} && $env->{'PATHINFO'} =~ s{^ (/foo) (?= $ | /) }{}x) {\n$env->{'SCRIPTNAME'} = $1;\nreturn \\&fooapp;\n}\n\nreturn $self->SUPER::findpsgihandler($env);\n}\n\n\"app\"\nReturn a reference to the application being served. This should be a valid PSGI application.\nSee PSGI. By default it will look at the value of the \"app\" configuration option. The \"app\"\nmethod may also be used to set the \"app\" configuration option.\n\npackage MyApp;\nuse base qw(Net::Server::PSGI);\n\nsub defaultservertype { 'Prefork' }\n\nsub myapp {\nmy $env = shift;\nreturn [200, ['Content-type', 'text/html'], [\"Hello world\"]];\n}\n\n\nMyApp->run(app => \\&myapp);\n\n\n# OR\nsub app { \\&myapp }\nMyApp->run;\n\n\n# OR\nmy $server = MyApp->new;\n$server->app(\\&myapp);\n$server->run;\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "In addition to the command line arguments of the Net::Server::HTTP base classes you can also set\nthe following options.\n\napp Should return a coderef of the PSGI application. Is returned by the app method.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Paul T. Seamons paul@seamons.com\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Please see also Plack, Starman,\n\nNet::Server::Fork, Net::Server::INET, Net::Server::PreFork, Net::Server::PreForkSimple,\nNet::Server::MultiType, Net::Server::Single Net::Server::SIG Net::Server::Daemonize\nNet::Server::Proto Net::Server::HTTP\n",
                "subsections": []
            }
        }
    }
}