View Source Plug_CGI
A Plug adapter for the Common Gateway Interface, allowing you to use all your favorite middleware and tools with the simplicity of CGI web servers.
See the Plug documentation for more information.
example
Example
There are more examples in the
cgi-bin
folder.
#!/usr/bin/env elixir
# Install plug_cgi as a dependency
Mix.install([
:plug_cgi
])
# Define your plug
# You can use middleware, routing, or anything else
defmodule MyPlug do
import Plug.Conn
def init(options) do
# initialize options
options
end
def call(conn, _opts) do
conn
|> put_resp_content_type("text/plain")
|> send_resp(200, "Hello world")
end
end
# Run your plug with plug_cgi
Plug.CGI.run MyPlug
installation
Installation
If available in Hex, the package can be installed
by adding plug_cgi
to your list of dependencies in mix.exs
:
def deps do
[
{:plug_cgi, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/plug_cgi.