Presto offers a full set of utilities needed to Quickly build Speedy web applications
It adds only 3 methods to controllers:
http, view and ctrl
Any module containing Presto controllers can be mounted into any Presto app
Presto offers fine-grained control over applications, slices, controllers and actions
It has Controllers, Actions, Hooks, Helpers etc., as well as any tool/utility supposed to be present in a modern web framework.
Click Here for an introductory tutorial.
Presto was designed as a hyper-thin wrapper around Rack. A wrapper that adds as low overhead as possible.
Currently, Presto adds only about 25-30% of overhead.
So, when Rack performs at about 7000 requests per second, Presto performs at about 5000 requests per second!
Yes, 5000 requests per second is the native Presto speed.
And Yes, it is a
feature full framework
.
Presto organizing all the tools/utilities into a convenient Api, rather than simply throw them into controllers.
I.e., HTTP Api includes all http related methods, like
params,
env,
path,
session,
cookies etc.
View Api includes all template engine methods, like
render,
render_partial,
render_layout etc.
Presto supports 3 authorization types:
Basic Auth:
http.auth do |user, pass|
user == 'admin' &&
pass == 'someScrtPswd'
end
More...
By default, any action has
halt, forward and redirect
capabilities enabled,
as well as read/write access to session and
cookies.
To create more restrictive actions,
use http.confine method inside a hook:
http.before do
http.confine
end
More...
Cache module will store the response returned by action and will return it on next requests without executing action.
To enable cache, simply call http.cache with a block:
http.cache { true }
If given block returns :update [Symbol], cache for current action will be updated.
If given block returns :purge [Symbol], cache for current controller will be updated.
More...Templates compilation is a time consuming operation. Even worse, it is blocking app while templates are read from file system.
A proper solution would be to compile templates only once, then render them constantly on each request.
To enable compiler, simply do:
view.compile do
true # or :update or :purge
end
More...
Presto uses inline testing, meant you can write logic and tests using same ink on same paper.
# defining action
def index
'ok'
end
# testing action
ctrl.spec 'Ok Test' do
Should 'return ok' do
response = get
is(response.body) == 'ok'
end
end
More...
As simple as:
class Cms
include Presto
http.map
http.rewrite /(.*)\.php$/i do |name|
"page/#{ name }.html"
end
end
Rewrite rules can be set at both slice and controller levels.