lib/spire/router.rb in spire-0.3.3 vs lib/spire/router.rb in spire-0.4.0
- old
+ new
@@ -11,13 +11,12 @@
@request = {"controller" => req[1], "action" => req[2]}
end
def route
@app["controller"] = nil
-
- if @request["controller"] == "public"
- self.return_file
+ if @request["controller"] == "favicon.ico"
+ return self.return_file("favicon.ico")
end
if @request["controller"] == nil
route = @routes['default'].split("#")
@app["controller"] = route[0].capitalize
@@ -34,19 +33,19 @@
@app["action"] = values[1]
end
end
end
- unless @app["controller"]
- return Error.new :status => 404
+ unless @app["controller"]
+ return Error.new :message => "404 // Route not found in system/routes.rb", :status => 404
end
return self.run
end
- def return_file
- result = Public.new :file => "test.html", :render => true
+ def return_file(file)
+ result = Public.new :file => file, :render => true
file = result.extension_check
return Response.new(file[:file], file[:content_type], 200)
end
def run
@@ -61,12 +60,12 @@
end
end
content_type = "text/html;"
status = 200
-
- if result == 404
- return Error.new :status => 404
+
+ if result == 404 or result == nil
+ return Error.new :message => "404 // No method/Response from method. See #{@app["controller"]}##{@app["action"]} and check for a response", :status => 404
end
if @class.instance_variable_get(:@status)
status = @class.instance_variable_get(:@status)
end