{"id":16302450,"url":"https://github.com/tokuhirom/p5-cgi-emulate-psgi","last_synced_at":"2025-03-22T19:34:55.950Z","repository":{"id":691487,"uuid":"335700","full_name":"tokuhirom/p5-cgi-emulate-psgi","owner":"tokuhirom","description":"CGI::Emulate::PSGI","archived":false,"fork":false,"pushed_at":"2017-05-08T04:46:05.000Z","size":87,"stargazers_count":11,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T14:12:18.519Z","etag":null,"topics":["cgi","perl","psgi"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tokuhirom.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-10-13T06:13:07.000Z","updated_at":"2021-09-16T13:42:57.000Z","dependencies_parsed_at":"2022-08-16T10:45:15.004Z","dependency_job_id":null,"html_url":"https://github.com/tokuhirom/p5-cgi-emulate-psgi","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokuhirom%2Fp5-cgi-emulate-psgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokuhirom%2Fp5-cgi-emulate-psgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokuhirom%2Fp5-cgi-emulate-psgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokuhirom%2Fp5-cgi-emulate-psgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tokuhirom","download_url":"https://codeload.github.com/tokuhirom/p5-cgi-emulate-psgi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245013749,"owners_count":20547175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgi","perl","psgi"],"created_at":"2024-10-10T20:57:46.809Z","updated_at":"2025-03-22T19:34:55.596Z","avatar_url":"https://github.com/tokuhirom.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nCGI::Emulate::PSGI - PSGI adapter for CGI\n\n# SYNOPSIS\n\n    my $app = CGI::Emulate::PSGI-\u003ehandler(sub {\n        # Existing CGI code\n    });\n\n# DESCRIPTION\n\nThis module allows an application designed for the CGI environment to\nrun in a PSGI environment, and thus on any of the backends that PSGI\nsupports.\n\nIt works by translating the environment provided by the PSGI\nspecification to one expected by the CGI specification. Likewise, it\ncaptures output as it would be prepared for the CGI standard, and\ntranslates it to the format expected for the PSGI standard using\n[CGI::Parse::PSGI](https://metacpan.org/pod/CGI::Parse::PSGI) module.\n\n# CGI.pm\n\nIf your application uses [CGI](https://metacpan.org/pod/CGI), be sure to cleanup the global\nvariables in the handler loop yourself, so:\n\n    my $app = CGI::Emulate::PSGI-\u003ehandler(sub {\n        use CGI;\n        CGI::initialize_globals();\n        my $q = CGI-\u003enew;\n        # ...\n    });\n\nOtherwise previous request variables will be reused in the new\nrequests.\n\nAlternatively, you can install and use [CGI::Compile](https://metacpan.org/pod/CGI::Compile) from CPAN and\ncompiles your existing CGI scripts into a sub that is perfectly ready\nto be converted to PSGI application using this module.\n\n    my $sub = CGI::Compile-\u003ecompile(\"/path/to/script.cgi\");\n    my $app = CGI::Emulate::PSGI-\u003ehandler($sub);\n\nThis will take care of assigning a unique namespace for each script\netc. See [CGI::Compile](https://metacpan.org/pod/CGI::Compile) for details.\n\nYou can also consider using [CGI::PSGI](https://metacpan.org/pod/CGI::PSGI) but that would require you to\nslightly change your code from:\n\n    my $q = CGI-\u003enew;\n    # ...\n    print $q-\u003eheader, $output;\n\ninto:\n\n    use CGI::PSGI;\n\n    my $app = sub {\n        my $env = shift;\n        my $q = CGI::PSGI-\u003enew($env);\n        # ...\n        return [ $q-\u003epsgi_header, [ $output ] ];\n    };\n\nSee [CGI::PSGI](https://metacpan.org/pod/CGI::PSGI) for details.\n\n# METHODS\n\n- handler\n\n        my $app = CGI::Emulate::PSGI-\u003ehandler($code);\n\n    Creates a PSGI application code reference out of CGI code reference.\n\n- emulate\\_environment\n\n        my %env = CGI::Emulate::PSGI-\u003eemulate_environment($env);\n\n    Creates an environment hash out of PSGI environment hash. If your code\n    or framework just needs an environment variable emulation, use this\n    method like:\n\n        local %ENV = (%ENV, CGI::Emulate::PSGI-\u003eemulate_environment($env));\n        # run your application\n\n    If you use `handler` method to create a PSGI environment hash, this\n    is automatically called in the created application.\n\n# AUTHOR\n\nTokuhiro Matsuno \u003ctokuhirom@cpan.org\u003e\n\nTatsuhiko Miyagawa\n\n# COPYRIGHT AND LICENSE\n\nCopyright (c) 2009-2010 by tokuhirom.\n\nThis program is free software; you can redistribute\nit and/or modify it under the same terms as Perl itself.\n\nThe full text of the license can be found in the\nLICENSE file included with this module.\n\n# SEE ALSO\n\n[PSGI](https://metacpan.org/pod/PSGI) [CGI::Compile](https://metacpan.org/pod/CGI::Compile) [CGI::PSGI](https://metacpan.org/pod/CGI::PSGI) [Plack](https://metacpan.org/pod/Plack) [CGI::Parse::PSGI](https://metacpan.org/pod/CGI::Parse::PSGI)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokuhirom%2Fp5-cgi-emulate-psgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokuhirom%2Fp5-cgi-emulate-psgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokuhirom%2Fp5-cgi-emulate-psgi/lists"}