stubs/project/content/config.ru.rbt in rango-0.1.pre vs stubs/project/content/config.ru.rbt in rango-0.1.0
- old
+ new
@@ -1,13 +1,15 @@
-<%= shebang "rackup", ["-s", "thin", "-p", 4000] %>
+<%= shebang "./init.rb", %w[-p 4000 -s webrick] %>
# encoding: utf-8
-# TODO: how to change environment from CLI?
-require_relative "init"
+# Load init.rb even if config.ru is just loaded
+# This comes handy in Passenger etc, but it's still
+# useful to have config.ru as an executable, because
+# it's easy to have default arguments for bin/rackup
+require_relative "init.rb" unless $0.eql?(__FILE__)
+<% if @warden %>
-use Rango::Middlewares::Basic
-
# warden authentication
# wiki.github.com/hassox/warden/setup
require "warden"
use Warden::Manager do |manager|
@@ -30,5 +32,31 @@
Warden::Strategies.add(:password) do
def authenticate!
User.new # TODO
end
end
+<% end %>
+
+Rango::Router.use(:<%= @router.to_sym %>)
+
+<% case @router %>
+<% when "usher" %>
+# http://github.com/joshbuddy/usher
+Project.router = Usher::Interface.for(:rack) do
+ get("/").to(<%= @name.camel_case %>::ShowCase.dispatcher(:index)).name(:showcase)
+end
+<% when "rack-mount" %>
+# http://github.com/josh/rack-mount
+Project.router = Rack::Mount::RouteSet.new do |set|
+ # add_route takes a rack application and conditions to match with
+ # conditions may be strings or regexps
+ # See Rack::Mount::RouteSet#add_route for more options.
+ set.add_route <%= @name.camel_case %>::ShowCase.dispatcher(:index), method: "get", path: "/"
+end
+<% when "rack-router" %>
+# TODO: routes
+<% when "urlmap" %>
+# TODO: routes
+<% end %>
+
+use Rango::Middlewares::Basic
+run Project.router