We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Add a 'PassengerDisable' per-directory config option for people who want 
to disable Passenger for certain URLs. Useful when the virtual host is a 
mix of a Rails app and a PHP app.
Hongli Lai (Phusion) (author)
Fri Jul 25 06:38:30 -0700 2008
commit  d7a3f3baae92e8d300780f4069c97ca6d42a19fa
tree    df86d0a3f44e523b3d5ce38fe32e53a95334f574
parent  2de5e1c93be18d167b69d0a1b95ca76e4fccece5
...
58
59
60
 
61
62
63
...
76
77
78
 
 
79
80
81
...
273
274
275
 
 
 
 
 
 
 
276
277
278
...
406
407
408
409
 
 
 
410
411
412
...
450
451
452
 
 
 
 
 
453
454
455
...
58
59
60
61
62
63
64
...
77
78
79
80
81
82
83
84
...
276
277
278
279
280
281
282
283
284
285
286
287
288
...
416
417
418
 
419
420
421
422
423
424
...
462
463
464
465
466
467
468
469
470
471
472
0
@@ -58,6 +58,7 @@ extern "C" {
0
 void *
0
 passenger_config_create_dir(apr_pool_t *p, char *dirspec) {
0
   DirConfig *config = create_dir_config_struct(p);
0
+ config->enabled = DirConfig::UNSET;
0
   config->autoDetectRails = DirConfig::UNSET;
0
   config->autoDetectRack = DirConfig::UNSET;
0
   config->autoDetectWSGI = DirConfig::UNSET;
0
@@ -76,6 +77,8 @@ passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv) {
0
   DirConfig *base = (DirConfig *) basev;
0
   DirConfig *add = (DirConfig *) addv;
0
   
0
+ config->enabled = (add->enabled == DirConfig::UNSET) ? base->enabled : add->enabled;
0
+
0
   config->railsBaseURIs = base->railsBaseURIs;
0
   for (set<string>::const_iterator it(add->railsBaseURIs.begin()); it != add->railsBaseURIs.end(); it++) {
0
     config->railsBaseURIs.insert(*it);
0
@@ -273,6 +276,13 @@ cmd_passenger_default_user(cmd_parms *cmd, void *dummy, const char *arg) {
0
   return NULL;
0
 }
0
 
0
+static const char *
0
+cmd_passenger_disable(cmd_parms *cmd, void *pcfg) {
0
+ DirConfig *config = (DirConfig *) pcfg;
0
+ config->enabled = DirConfig::DISABLED;
0
+ return NULL;
0
+}
0
+
0
 
0
 /*************************************************
0
  * Rails-specific settings
0
@@ -406,7 +416,9 @@ cmd_rails_spawn_server(cmd_parms *cmd, void *pcfg, const char *arg) {
0
 }
0
 
0
 
0
-typedef const char * (*Take1Func)(); // Workaround for some weird C++-specific compiler error.
0
+// Workaround for some weird C++-specific compiler error.
0
+typedef const char * (*Take0Func)();
0
+typedef const char * (*Take1Func)();
0
 
0
 const command_rec passenger_commands[] = {
0
   // Passenger settings.
0
@@ -450,6 +462,11 @@ const command_rec passenger_commands[] = {
0
     NULL,
0
     RSRC_CONF,
0
     "The user that Rails/Rack applications must run as when user switching fails or is disabled."),
0
+ AP_INIT_NO_ARGS("PassengerDisable",
0
+ (Take0Func) cmd_passenger_disable,
0
+ NULL,
0
+ OR_ALL,
0
+ "Completely disable Phusion Passenger."),
0
 
0
   // Rails-specific settings.
0
   AP_INIT_TAKE1("RailsBaseURI",
...
47
48
49
 
 
50
51
52
...
47
48
49
50
51
52
53
54
0
@@ -47,6 +47,8 @@
0
     struct DirConfig {
0
       enum Threeway { ENABLED, DISABLED, UNSET };
0
       
0
+ Threeway enabled;
0
+
0
       std::set<std::string> railsBaseURIs;
0
       std::set<std::string> rackBaseURIs;
0
       
...
629
630
631
632
633
 
 
 
 
 
634
635
636
...
788
789
790
 
 
 
 
791
792
793
...
629
630
631
 
632
633
634
635
636
637
638
639
640
...
792
793
794
795
796
797
798
799
800
801
0
@@ -629,8 +629,12 @@ public:
0
   }
0
   
0
   int handleRequest(request_rec *r) {
0
- TRACE_POINT();
0
     DirConfig *config = getDirConfig(r);
0
+ if (config->enabled == DirConfig::DISABLED) {
0
+ return DECLINED;
0
+ }
0
+
0
+ TRACE_POINT();
0
     DirectoryMapper mapper(r, config);
0
     if (mapper.getBaseURI() == NULL || r->filename == NULL || fileExists(r->filename)) {
0
       return DECLINED;
0
@@ -788,6 +792,10 @@ public:
0
   int
0
   mapToStorage(request_rec *r) {
0
     DirConfig *config = getDirConfig(r);
0
+ if (config->enabled == DirConfig::DISABLED) {
0
+ return DECLINED;
0
+ }
0
+
0
     DirectoryMapper mapper(r, config);
0
     bool forwardToApplication;
0
     

Comments