{"id":18000174,"url":"https://github.com/publica-re/phoenix_cgi","last_synced_at":"2025-04-04T07:44:01.158Z","repository":{"id":57531800,"uuid":"291480620","full_name":"publica-re/phoenix_cgi","owner":"publica-re","description":"A small CGI controller for Phoenix","archived":false,"fork":false,"pushed_at":"2020-08-30T14:10:54.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T19:14:17.562Z","etag":null,"topics":["cgi","elixir","phoenix"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/publica-re.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-30T13:57:02.000Z","updated_at":"2020-08-30T17:47:04.000Z","dependencies_parsed_at":"2022-08-26T03:51:21.537Z","dependency_job_id":null,"html_url":"https://github.com/publica-re/phoenix_cgi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Fphoenix_cgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Fphoenix_cgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Fphoenix_cgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Fphoenix_cgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/publica-re","download_url":"https://codeload.github.com/publica-re/phoenix_cgi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142043,"owners_count":20890652,"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","elixir","phoenix"],"created_at":"2024-10-29T23:10:02.564Z","updated_at":"2025-04-04T07:44:01.135Z","avatar_url":"https://github.com/publica-re.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PhoenixCGI\n\nA small CGI controller for Phoenix.\n\n---\n\n## Setup\n\nAdd `PhoenixCGI` to your `deps` in `mix.exs`:\n\n```elixir\ndefp deps do\n  [\n    {:phoenix_cgi, \"~\u003e 0.1\"},\n    ...\n  ]\nend\n```\n\nthen, and that's really important, in your `endpoint.ex`, add the following `body_reader` in your `plug Plug.Parsers`:\n\n```elixir\nplug Plug.Parsers,\n  body_reader: {PhoenixCGI.CacheRawBody, :read_body, []},\n  ...\n```\n\nThis will cause the body of your request to be saved in a private field, so that we will be able to\npass it to the CGI scripts.\n\n## Usage\n\nYou will then be able to use `PhoenixCGI` as any controller. For instance, if you want to serve `git-http-backend` on a\n`/git/` to serve all repositories in `/opt/git/repos/`, you can setup as follows:\n\n```elixir\nmatch :*, \"/git/*path\", PhoenixCGI,\n  binary: \"/usr/lib/git-core/git-http-backend\",\n  extra_env: %{\n    GIT_PROJECT_ROOT: \"/opt/git/repos/\",\n    GIT_HTTP_EXPORT_ALL: \"1\"\n  }\n```\n\nYou can also define a plug that will define, for instance, which project to serve, with `assign/3`.\n\n```elixir\ndefp set_repo(conn) do\n  assign(conn, :extra_env, %{\n    GIT_PROJECT_ROOT: \"/opt/git/repos/demo.git\",\n    GIT_HTTP_EXPORT_ALL: \"1\"\n  })\nend\n```\n\nand then use it\n\n```elixir\npipeline :git do\n  plug :set_repo\nend\n\nscope \"/\" do\n  pipe_through :git\n\n  match :*, \"/git/*path\", PhoenixCGI,\n    binary: \"/usr/lib/git-core/git-http-backend\"\nend\n```\n\n## Documentation\n\nThe documentation is available on [hexdocs](https://hexdocs.pm/phoenix_cgi/0.1.0/PhoenixCGI.html#content).\n\n## Licence\n\nCopyright (C) 2020 David Baumgartner\n\nThis program is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation, either version 3 of the License, or (at your option)\nany later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\nmore details.\n\nYou should have received a copy of the GNU General Public License along\nwith this program. If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n\n## Contribution\n\nI happily accept pull requests through [GitHub](https://github.com/publica-re/phoenix_cgi).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublica-re%2Fphoenix_cgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublica-re%2Fphoenix_cgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublica-re%2Fphoenix_cgi/lists"}