Module: Lively::Environment::Middleware

Included in:
Application, HTTP, HTTY
Defined in:
lib/lively/environment/middleware.rb

Overview

Shared middleware configuration for Lively application environments.

Provides the application class resolver, asset middleware, and the Lively middleware stack. Included by both HTTP and HTTY environments.

Instance Method Summary collapse

Instance Method Details

#applicationObject

Resolve the application class to use.



28
29
30
31
32
33
34
35
# File 'lib/lively/environment/middleware.rb', line 28

def application
	if Object.const_defined?(:Application)
		Object.const_get(:Application)
	else
		Console.warn(self, "No Application class defined, using default.")
		::Lively::Application
	end
end

#middlewareObject

Build the middleware stack for this application.



39
40
41
42
43
44
45
# File 'lib/lively/environment/middleware.rb', line 39

def middleware
	::Protocol::HTTP::Middleware.build do |builder|
		builder.use Lively::Assets, root: File.expand_path("public", self.root)
		builder.use Lively::Assets, root: File.expand_path("../../../public", __dir__)
		builder.use self.application
	end
end

#rootObject

Get the root directory for this application.



22
23
24
# File 'lib/lively/environment/middleware.rb', line 22

def root
	Dir.pwd
end