elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.84k stars 582 forks source link

Error in Bandit example #1146

Closed etnt closed 1 year ago

etnt commented 1 year ago

In the first "hello world" example with the bandit webserver using websockets, I get the following crash:

** (EXIT from #PID<0.95.0>) shutdown: failed to start child: {Bandit, #Reference<0.1586837308.1872232450.204926>}                                                                                                    
    ** (EXIT) an exception was raised:                                                                                                                                                                               
        ** (RuntimeError) Unsupported keys(s) in top level config: [:options]                                                                                                                                        
            (bandit 0.7.7) lib/bandit.ex:382: Bandit.validate_options/3                                                                                                                                              
            (bandit 0.7.7) lib/bandit.ex:280: Bandit.start_link/1                                                                                                                                                    
            (stdlib 4.3) supervisor.erl:414: :supervisor.do_start_child_i/3                                                                                                                                          
            (stdlib 4.3) supervisor.erl:400: :supervisor.do_start_child/2                                                                                                                                            
            (stdlib 4.3) supervisor.erl:384: anonymous fn/3 in :supervisor.start_children/2                                                                                                                          
            (stdlib 4.3) supervisor.erl:1250: :supervisor.children_map/4                                                                                                                                             
            (stdlib 4.3) supervisor.erl:350: :supervisor.init_children/2                                                                                                                                             
            (stdlib 4.3) gen_server.erl:851: :gen_server.init_it/2          

The problem seem to be the way options is specified. By doing this change, the example seem to work:

-webserver = {Bandit, plug: Router, scheme: :http, options: [port: 4000]}
+webserver = {Bandit, plug: Router, scheme: :http, port: 4000}
whatyouhide commented 1 year ago

Good find! Any chance you want to send a PR with a fix? 😌

etnt commented 1 year ago

will do

whatyouhide commented 1 year ago

Closed by #1147.