Skip to content

Commit 98763da

Browse files
committed
Expand HTTP server docs
1 parent 7629b58 commit 98763da

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

lib/test_server.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ defmodule TestServer do
429429
@doc """
430430
Adds a route to a test server instance.
431431
432-
See `plug/1` for options.
432+
See `plug/1` for more.
433433
"""
434434
@spec plug(pid(), module() | function()) :: :ok
435435
def plug(instance, plug) do
@@ -459,6 +459,8 @@ defmodule TestServer do
459459

460460
@doc """
461461
Fetches the generated x509 suite for a test server instance.
462+
463+
See `x509_suite/0` for more.
462464
"""
463465
@spec x509_suite(pid()) :: term()
464466
def x509_suite(instance) do

lib/test_server/http_server/bandit.ex

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
if Code.ensure_loaded?(Bandit) do
22
defmodule TestServer.HTTPServer.Bandit do
3-
@moduledoc false
3+
@moduledoc """
4+
HTTP server adapter using `Bandit`.
45
5-
alias TestServer.WebSocket
6+
By default only one acceptor process is started which is enough for
7+
testing. This adapter will be used by default if `Bandit` is loaded in the
8+
project.
9+
10+
## Usage
611
12+
TestServer.start(
13+
http_server: {TestServer.HTTPServer.Bandit, bandit_options}
14+
)
15+
"""
716
@behaviour TestServer.HTTPServer
817
@behaviour WebSock
918

19+
alias TestServer.WebSocket
20+
1021
@impl TestServer.HTTPServer
1122
def start(instance, port, scheme, options, bandit_options) do
1223
transport_options =

lib/test_server/http_server/httpd.ex

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
if Code.ensure_loaded?(:httpd) do
22
defmodule TestServer.HTTPServer.Httpd do
3-
@moduledoc false
3+
@moduledoc """
4+
HTTP server adapter using `:httpd`.
45
6+
This adapter will be used by default if there is no `Bandit` or
7+
`Plug.Cowboy` loaded in the project.
8+
9+
## Usage
10+
11+
TestServer.start(
12+
http_server: {TestServer.HTTPServer.Httpd, httpd_options}
13+
)
14+
"""
515
@behaviour TestServer.HTTPServer
616

717
@impl TestServer.HTTPServer
@@ -42,12 +52,13 @@ if Code.ensure_loaded?(:httpd) do
4252
# :httpd record handler
4353
require Record
4454

45-
Record.defrecord(
55+
Record.defrecordp(
4656
:httpd,
4757
Record.extract(:mod, from_lib: "inets/include/httpd.hrl") ++
4858
[handler_plug: :undefined, websocket: :undefined]
4959
)
5060

61+
@doc false
5162
def unquote(:do)(data) do
5263
{plug, opts} = :httpd_util.lookup(httpd(data, :config_db), :handler_plug)
5364

lib/test_server/http_server/plug_cowboy.ex

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
if Code.ensure_loaded?(Plug.Cowboy) do
22
defmodule TestServer.HTTPServer.Plug.Cowboy do
3-
@moduledoc false
3+
@moduledoc """
4+
HTTP server adapter using `Plug.Cowboy`.
5+
6+
This adapter will be used by default if `Bandit` is not loaded and
7+
`Plug.Cowboy` is loaded in the project.
8+
9+
## Usage
10+
11+
TestServer.start(
12+
http_server: {TestServer.HTTPServer.Plug.Cowboy, cowboy_options}
13+
)
14+
"""
415

516
# Server
617

mix.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ defmodule TestServer.MixProject do
7575
],
7676
skip_undefined_reference_warnings_on: [
7777
"CHANGELOG.md"
78+
],
79+
groups_for_modules: [
80+
HTTPServer: [
81+
TestServer.HTTPServer,
82+
TestServer.HTTPServer.Httpd,
83+
TestServer.HTTPServer.Bandit,
84+
TestServer.HTTPServer.Plug.Cowboy
85+
]
7886
]
7987
]
8088
end

0 commit comments

Comments
 (0)