rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* can I use Rack::Directory inside Rack::Builder block?
@ 2010-05-24  7:18 Stephen Bannasch
  2010-05-24 17:56 ` Stephen Bannasch
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Bannasch @ 2010-05-24  7:18 UTC (permalink / raw)
  To: rack-devel

I want to emulate a static web server with directory indexes using rack.

Is there a way to use Rack::Directory inside a Rack::Builder block?

This works fine serving static files:

   myapp = Rack::Builder.new do
     map "/" do
       use Rack::Static, :urls => ["/"], :root => 'cache'
       run lambda {|env| [404, {}, '']}
     end
   end

   Rack::Handler::WEBrick.run(myapp, :Port => 4321)

But when I add Rack::Directory

   myapp = Rack::Builder.new do
     map "/" do
       use Rack::Static, :urls => ["/"], :root => 'cache'
       use Rack::Directory, 'cache'
       run lambda {|env| [404, {}, '']}
     end
   end

   Rack::Handler::WEBrick.run(myapp, :Port => 4321)

I'm getting this error:

   rack-1.1.0/lib/rack/directory.rb:46:in `initialize': can't convert Proc into String (TypeError)
           from ./rack-1.1.0/lib/rack/builder.rb:54:in `new'
           from ./rack-1.1.0/lib/rack/builder.rb:54:in `use'
           from ./rack-1.1.0/lib/rack/builder.rb:73:in `call'
           from ./rack-1.1.0/lib/rack/builder.rb:73:in `to_app'
           from ./rack-1.1.0/lib/rack/builder.rb:73:in `each'
           from ./rack-1.1.0/lib/rack/builder.rb:73:in `inject'
           from ./rack-1.1.0/lib/rack/builder.rb:73:in `to_app'
           from ./rack-1.1.0/lib/rack/builder.rb:63:in `map'
           from ./rack-1.1.0/lib/rack/builder.rb:66:in `map'

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <p06240801c81fd6be2bb9@192.168.1.106>]

end of thread, other threads:[~2010-05-25  1:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-24  7:18 can I use Rack::Directory inside Rack::Builder block? Stephen Bannasch
2010-05-24 17:56 ` Stephen Bannasch
     [not found] <p06240801c81fd6be2bb9@192.168.1.106>
     [not found] ` <p06240801c8206c949189@63.138.152.134>
2010-05-24 20:16   ` Magnus Holm
2010-05-25  0:42     ` Stephen Bannasch
2010-05-25  1:14       ` James Tucker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).