Skip to content

Commit 792c7ce

Browse files
committed
Invert order of bandit opt overrides
1 parent 7a19c0e commit 792c7ce

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

lib/hap.ex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,21 @@ defmodule HAP do
8686
def init(%HAP.AccessoryServer{} = accessory_server) do
8787
accessory_server = accessory_server |> HAP.AccessoryServer.compile()
8888

89+
bandit_opts =
90+
[
91+
plug: HAP.HTTPServer,
92+
port: 0,
93+
http_1_options: [clear_process_dict: false],
94+
thousand_island_options: [handler_module: HAP.HAPSessionHandler, transport_module: HAP.HAPSessionTransport]
95+
]
96+
|> Keyword.merge(accessory_server.bandit_opts)
97+
8998
children = [
9099
{HAP.PersistentStorage, accessory_server.data_path},
91100
{HAP.AccessoryServerManager, accessory_server},
92101
HAP.EventManager,
93102
HAP.PairSetup,
94-
{Bandit,
95-
Keyword.merge(
96-
accessory_server.bandit_opts,
97-
plug: HAP.HTTPServer,
98-
port: 0,
99-
http_1_options: [clear_process_dict: false],
100-
thousand_island_options: [handler_module: HAP.HAPSessionHandler, transport_module: HAP.HAPSessionTransport]
101-
)}
103+
{Bandit, bandit_opts}
102104
]
103105

104106
Supervisor.init(children, strategy: :rest_for_one)

lib/hap/accessory_server.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ defmodule HAP.AccessoryServer do
3232
If it is `:host` then a value of `hap_data` is used. If it is anything else (as it will be
3333
when compiling for a Nerves target, for example), the value of `/root/hap_data` is used. This
3434
allows HAP to work out-of-the-box in conventional and Nerves environments.
35-
* `bandit_opts`: Options to pass to Bandit. The values provided will be merged with a number of
36-
fixed options required for proper operation; see lib/hap.ex for details.
35+
* `bandit_opts`: Options to pass to Bandit. The values provided merged with HAP's default
36+
options, many of which are required for proper operation. Care must be taken to ensure that such
37+
options are not overwritten; see lib/hap.ex for details.
3738
* `accessory_type`: A HAP specified value indicating the primary function of this
3839
device. See `t:HAP.AccessoryServer.accessory_type/0` for details
3940
* `accessories`: A list of `HAP.Accessory` structs to include in this accessory server

0 commit comments

Comments
 (0)