# `TestServer.HTTPServer`
[🔗](https://github.com/danschultzer/test_server/blob/v0.1.22/lib/test_server/http_server.ex#L1)

HTTP server adapter module.

## Usage

    defmodule MyApp.MyHTTPServer do
      @behaviour TestServer.HTTPServer

      @impl TestServer.HTTPServer
      def start(instance, port, scheme, tls_options, server_options) do
        my_http_server_options =
          server_options
          |> Keyword.put(:port, port)
          |> Keyword.put_new(:ipfamily, options[:ipfamily])

        case MyHTTPServer.start(my_http_server_options) do
          {:ok, pid} -> {:ok, pid, my_http_server_options}
          {:error, error} -> {:error, error}
        end
      end

      @impl TestServer.HTTPServer
      def stop(instance, server_options), do: MyHTTPServer.stop()

      @impl TestServer.HTTPServer
      def get_socket_pid(%{adapter: {_, data}}), do: data.pid # or however your adapter provides the pid
    end

# `instance`

```elixir
@type instance() :: pid()
```

# `options`

```elixir
@type options() :: [tls: keyword(), ipfamily: :inet | :inet6]
```

# `port_number`

```elixir
@type port_number() :: :inet.port_number()
```

# `scheme`

```elixir
@type scheme() :: :http | :https
```

# `server_options`

```elixir
@type server_options() :: keyword()
```

# `get_socket_pid`

```elixir
@callback get_socket_pid(Plug.Conn.t()) :: pid()
```

# `start`

```elixir
@callback start(instance(), port_number(), scheme(), options(), server_options()) ::
  {:ok, pid(), server_options()} | {:error, any()}
```

# `stop`

```elixir
@callback stop(instance(), server_options()) :: :ok | {:error, any()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
