Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only create the Toto::Site instance once

  • Loading branch information...
commit eb87c792d7e79f7c31183830d7de517b763fa3f9 1 parent 0393dfd
@evaryont evaryont authored Alexis Sellier committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/toto.rb
View
5 lib/toto.rb
@@ -311,11 +311,12 @@ def set key, val = nil, &blk
end
class Server
- attr_reader :config
+ attr_reader :config, :site
def initialize config = {}, &blk
@config = config.is_a?(Config) ? config : Config.new(config)
@config.instance_eval(&blk) if block_given?
+ @site = Toto::Site.new(@config)
end
def call env
@@ -327,7 +328,7 @@ def call env
path, mime = @request.path_info.split('.')
route = (path || '/').split('/').reject {|i| i.empty? }
- response = Toto::Site.new(@config).go(route, *(mime ? mime : []))
+ response = @site.go(route, *(mime ? mime : []))
@response.body = [response[:body]]
@response['Content-Length'] = response[:body].length.to_s unless response[:body].empty?
Please sign in to comment.
Something went wrong with that request. Please try again.