Module: Roda::RodaPlugins::BridgetownServer::InstanceMethods
- Defined in:
- bridgetown-core/lib/roda/plugins/bridgetown_server.rb
Instance Method Summary collapse
-
#deconstruct_keys ⇒ Object
This is useful if you’re passing the Roda app instance around and want to get at
request
/response
easily as local variables. -
#initialize_bridgetown_context ⇒ Object
-
#initialize_bridgetown_root ⇒ Object
rubocop:todo Metrics/AbcSize.
Instance Method Details
#deconstruct_keys ⇒ Object
This is useful if you’re passing the Roda app instance around and want to
get at request
/ response
easily as local variables
145 146 147 |
# File 'bridgetown-core/lib/roda/plugins/bridgetown_server.rb', line 145 def deconstruct_keys(*) { request:, response: } end |
#initialize_bridgetown_context ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'bridgetown-core/lib/roda/plugins/bridgetown_server.rb', line 110 def initialize_bridgetown_context if self.class.opts[:bridgetown_site] # The site had previously been initialized via the bridgetown_ssr plugin Bridgetown::Current.sites[self.class.opts[:bridgetown_site].label] = self.class.opts[:bridgetown_site] @context ||= SiteContext.new({ site: self.class.opts[:bridgetown_site] }) end Bridgetown::Current.preloaded_configuration ||= self.class.opts[:bridgetown_preloaded_config] end |
#initialize_bridgetown_root ⇒ Object
rubocop:todo Metrics/AbcSize
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'bridgetown-core/lib/roda/plugins/bridgetown_server.rb', line 121 def initialize_bridgetown_root # rubocop:todo Metrics/AbcSize request.root do hook_result = instance_exec(&self.class.opts[:root_hook]) if self.class.opts[:root_hook] next hook_result if hook_result root_file = [ File.join(self.class.opts[:ssg_root], "index.html"), File.("generic_index.html", __dir__), ].find { File.exist?(_1) } status, headers, body = self.class.opts[:ssg_server].serving(request, root_file) response_headers = response.headers response_headers.replace(headers) request.halt [status, response_headers, body] rescue StandardError => e Bridgetown.logger.debug("Root handler error: #{e.}") response.status = 500 "<p>ERROR: cannot serve the root <code>index</code> file.</p>" end end |