-
Notifications
You must be signed in to change notification settings - Fork 46
Applications
Andrew Yaroshuk edited this page Jun 8, 2015
·
3 revisions
After you wrote your controllers, and maybe, middleware you must to setup your app. It is a good way to describe your app with a class, and then run its instance with serve
:
class TestApp < Base::App
# Rails-like approach to describe routes.It consists of path
# and string "controller_name#action_name"
# You can specify params to be captured:
# get "/users/:id", "users#show"
# sets developing mode middleware
settings.configure do |conf|
conf.environment = "development"
end
routes.draw do
all "/all/:id", "index#hello" # "id" will be available at request.ath_parameters"
get "/", "index#hello"
get "/bye", "index#bye"
# After you defined a controller, you have to register it in app with
# app.routes.register(NameController) where NameController is the class name
# of your controller.
register IndexController
end
# Middleware registering
use TimeLogger
end
# App creating
app = TestApp.new
app.serve
For now, Amethyst has two environments, that sets different middleware sets:
-
production
- all base middleware -
development
- all base middleware plus devtools, such as logging