Class: Grass::Front

Inherits:
Goliath::API
  • Object
show all
Includes:
Helper, Helpers::I18nHelper
Defined in:
lib/grass/endpoints/front.rb

Defined Under Namespace

Modules: Helper

Constant Summary collapse

DEFAULT_PAGE =
ENV['DEFAULT_PAGE'] || "index"

Constants included from Helpers::I18nHelper

Helpers::I18nHelper::DEV_IP, Helpers::I18nHelper::LNG_EXP_HTTP, Helpers::I18nHelper::LNG_EXP_PATH

Instance Method Summary collapse

Methods included from Helper

#request_data

Methods included from Helpers::I18nHelper

browser_locale, country_info, country_locales, language_info, locale, path_locale, remote_ip, set_locale

Instance Method Details

#get(env) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/grass/endpoints/front.rb', line 51

def get(env)
  
  set_locale

  id = get_id
  
  data = id =~ /scripts|styles/ ? {} : request_data
  
  headers = {}
  
  return fresh(id,data) if Grass.env == "development" && !config['enable_cache_for_development']

  # try memcache or render freshly
  if cached_response = Source.read_cache(Source.generate_cachekey(id,data))
    # puts "----> CACHED!!!"

    mime_type, body = cached_response
    headers = {"Content-Type" => mime_type}     
    status = 200   
      
  else
    status, headers, body = fresh(id,data)
    
  end
  
  [status,headers,body]

end

#response(env) ⇒ Object



47
48
49
# File 'lib/grass/endpoints/front.rb', line 47

def response(env)
  self.public_send env['REQUEST_METHOD'].downcase, env
end