I got some advice from Rick last night and started coding this handler to allow for time-based secure downloading similar to mod_secdownload that lighttpd offers. I got most of the code in the handler worked out and packaged into a gem but am still having the following problems: 1) I have a configuration script as follows require ''mongrel'' config = Mongrel::Configurator.new :host => "127.0.0.1" do listener do uri "/downloads", :handler => plugin(''/handlers/securedownload'',{:secret_string => "secret_string"}) end run end When I try ''listener :port => 3000 do'' I get a bind (port already in use) error. The script above however starts up but http://localhost:3000/downloads doesn''t start up the handler. The process method of my handler is never called, I just get a routing error from rails. 2) When I pass in the options to the plugin like this how do I get to the options hash while inside of the process method? Note: I also tried to get just the DirHandler example working and I couldn''t get the server to recognize that path either, so there might be something more sinister going on here. Any help appreciated. If I can get this to recognize my handler I''ll almost have it working. Is there a wiki I could do a writeup on as to how to write handlers after I get this finished? Josh Ferguson
On 5/26/06, Josh Ferguson <josh at besquared.net> wrote: [...]> > When I try ''listener :port => 3000 do'' I get a bind (port already in > use) error. >Have you tried ''netstat'' and see what process is using the port? [...]> > Note: I also tried to get just the DirHandler example working and I > couldn''t get the server to recognize that path either, so there might be > something more sinister going on here. >I agree, I left in the desert process that still is using the port. You could also try adding the handler using the configuration script of mongrel_rails, so that avoids problems with typos or anything in your configurator implementation.> Any help appreciated. If I can get this to recognize my handler I''ll > almost have it working. Is there a wiki I could do a writeup on as to > how to write handlers after I get this finished? >Whats your environment? OS, ruby -v, mongrel version, etc. No wiki yet, but write a draft and I think Zed will include in the official docs. Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi
On Fri, 2006-05-26 at 04:49 -0400, Josh Ferguson wrote:> When I try ''listener :port => 3000 do'' I get a bind (port already in > use) error. >Hey Josh, try a different port. Mostly likely you have something already running on 3000. If you are passing this to mongrel_rails with -S then you only need the "uri ..." statement. Not the whole Configurator class and so on.> The script above however starts up but http://localhost:3000/downloads > doesn''t start up the handler. The process method of my handler is never > called, I just get a routing error from rails. >Well, if you can run rails actions then handlers are working. You''ll have to first make sure it binds to the right port, or just use -S and pass it a file with only your "uri ..." statement. Then it should all work (with rails that is).> 2) When I pass in the options to the plugin like this how do I get to > the options hash while inside of the process method?Since you are using the plugin system, you get a few things for free: * listener is the listener that this handler is working with. * @options are the options that you were given. And @options is a hash. You can override this behavior by defining your own initialize method, and if you need something really really different then you can use the HttpHandler class which defines almost nothing.> > Note: I also tried to get just the DirHandler example working and I > couldn''t get the server to recognize that path either, so there might be > something more sinister going on here. >Well, considering it works for rails I''ll have to say you need to go back and review what you''ve done. If you''re passing the code you showed to -S then all you have to do is strip out everything but the "uri ..." line and it should pick right up.> Any help appreciated. If I can get this to recognize my handler I''ll > almost have it working. Is there a wiki I could do a writeup on as to > how to write handlers after I get this finished?http://mongrel.rubyforge.org/docs/contrib.html That''s instructions on how to contribute documentation. I''m avoiding a wiki until I can get a fixed set of documentation done up that the wiki could be based on. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/