Module: Roda::RodaPlugins::BridgetownServer::RequestMethods

Defined in:
bridgetown-core/lib/roda/plugins/bridgetown_server.rb

Instance Method Summary collapse

Instance Method Details

#bridgetownObject

Start up the Bridgetown routing system



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'bridgetown-core/lib/roda/plugins/bridgetown_server.rb', line 163

def bridgetown
  scope.initialize_bridgetown_context
  scope.initialize_bridgetown_root

  # Run the static file server
  ssg

  # There are two different code paths depending on if there's a site `base_path` configured
  if Bridgetown::Current.preloaded_configuration.base_path == "/"
    Bridgetown::Rack::Routes.load_all scope
    return
  end

  # Support custom base_path configurations
  on(Bridgetown::Current.preloaded_configuration.base_path.delete_prefix("/")) do
    Bridgetown::Rack::Routes.load_all scope
  end

  nil
end

#cookiesObject

Monkeypatch Roda/Rack’s Request object so it returns a hash which allows for indifferent access



157
158
159
160
# File 'bridgetown-core/lib/roda/plugins/bridgetown_server.rb', line 157

def cookies
  # TODO: maybe replace with a simpler hash that offers an overloaded `[]` method
  _previous_roda_cookies.with_indifferent_access
end