[Hiki-cvs 1643] hiki/hiki @ e2a74c2 [master] Hiki::Farm::Dispatcher#call: Return 404 for nonexistent pages

Back to archive index

Naohisa Goto null****@okkez*****
2014年 8月 6日 (水) 19:04:14 JST


Naohisa Goto	2014-08-06 19:04:14 +0900 (Wed, 06 Aug 2014)

  New Revision: e2a74c2e9573bb6e714868b4252f43fa9f9a9bca
  https://github.com/hiki/hiki/commit/e2a74c2e9573bb6e714868b4252f43fa9f9a9bca

  Merged 7fe3790: Merge pull request #59 from ngoto/mydevel

  Message:
    Hiki::Farm::Dispatcher#call: Return 404 for nonexistent pages

  Modified files:
    hiki/farm/dispatcher.rb

  Modified: hiki/farm/dispatcher.rb (+15 -1)
===================================================================
--- hiki/farm/dispatcher.rb    2014-08-06 15:35:55 +0900 (c2e9430)
+++ hiki/farm/dispatcher.rb    2014-08-06 19:04:14 +0900 (653beb9)
@@ -9,9 +9,23 @@ module Hiki
         when '/', "/#{Hiki::Farm::RSSPage.page_name}"
           Hiki::Farm::App.new(conf).call(env)
         when %r!\A/(\w+)/!
-          Hiki::App.new(File.join(conf.farm_root, $1, 'hikiconf.rb')).call(env)
+          hikiconf_rb = File.join(conf.farm_root, $1, 'hikiconf.rb')
+          if File.exist?(hikiconf_rb)
+            Hiki::App.new(hikiconf_rb).call(env)
+          else
+            not_found
+          end
+        else
+          not_found
         end
       end
+
+      private
+
+      def not_found
+        Hiki::Response.new("not found", 404, "Content-Type" => "text/plain")
+      end
+
     end
   end
 end




Hiki-cvs メーリングリストの案内
Back to archive index