From: Stephen Bannasch <stephen.bannasch@deanbrook.org>
To: rack-devel@googlegroups.com
Subject: can I use Rack::Directory inside Rack::Builder block?
Date: Mon, 24 May 2010 03:18:36 -0400 [thread overview]
Message-ID: <p06240801c81fd6be2bb9@[192.168.1.106]> (raw)
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'
next reply other threads:[~2010-05-24 7:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-24 7:18 Stephen Bannasch [this message]
2010-05-24 17:56 ` can I use Rack::Directory inside Rack::Builder block? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='p06240801c81fd6be2bb9@[192.168.1.106]' \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).