Support default_middleware configuration option
commit5985dd50a9bd72388dd5ca4886d6dffc083f87d4
authorJeremy Evans <code@jeremyevans.net>
Thu, 13 Sep 2018 17:48:25 +0000 (13 10:48 -0700)
committerEric Wong <e@80x24.org>
Fri, 21 Sep 2018 00:29:11 +0000 (21 00:29 +0000)
treea62dec60cfbfa8d0641207352f89b0538eef0319
parentc93a392385e7fe1ca3bf86cabe04f7591cef1a58
Support default_middleware configuration option

This allows for the equivalent of the
-N/--no-default_middleware command line option to be
specified in the configuration file so it doesn't
need to be specified on the command line every time
unicorn is executed.

It explicitly excludes the use of -N/--no-default_middleware
as an embedded configuration option in the rackup file, by
ignoring the options after ARGV is parsed.

In order to allow the configuration method to work, have
the lambda that Unicorn.builder returns accept two arguments.
Technically, only one argument is needed for the HttpServer
instance, but I'm guessing if the lambda accepts a single
argument, we expect that to be a rack application instead
of a lambda that returns a rack application.

The command line option option to disable default middleware
will take precedence over the unicorn configuration file option
if both are present.

For backwards compatibility, if the lambda passed to
HttpServer accepts 0 arguments, then call it without
arguments.

[ew: fix precedence for arity checking in build_app!
     configurator: ensure -N is respected when set in command-line]
bin/unicorn
lib/unicorn.rb
lib/unicorn/configurator.rb
lib/unicorn/http_server.rb