As you noticed, a middleware component for the rack, such as Rack::TryStatic , needs another application to send requests. You can create a simple one to use this, for example, just returned a 404 answer, for example:
app = lambda {|env| [404, {'Content-type' => 'text/plain'}, ['Not found'] run Rack::TryStatic.new app, :root => "build", :urls => %w[/], :try => ['.html']
or equivalently:
use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['.html'] run lambda {|env| [404, {'Content-type' => 'text/plain'}, ['Not found']]}
If you have your own 404 file, you can use the Rack::NotFound instead of your own endpoint:
use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['.html'] run Rack::NotFound.new('path/to/your/404.html')
If you are trying to use an array of file extensions :try , to try and serve, you can directly use Rack::File . Inside Rack::TryStatic uses Rack::Static , which in turn uses Rack::File . Unlike TryStatic and Static , Rack::File is a Rack application in its own right, so a separate application is not required to send requests. Then your config.ru will be simple:
run Rack::File.new './build'
although this would not allow bare requests to be served with the corresponding .html file, all requests would need to be fully qualified.