tzispa 0.4.14 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/tzispa/app.rb +2 -10
- data/lib/tzispa/controller/base.rb +3 -2
- data/lib/tzispa/controller/layout.rb +1 -18
- data/lib/tzispa/middleware.rb +9 -2
- data/lib/tzispa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cb6d1509d41c50ba037726c1873f83f1a8b3ab2
|
4
|
+
data.tar.gz: c31027f97f9e020a1374fe41701fa765df5718b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59623572733062ea7610fa746f39a5221112ee8eb09726a626cef6f349a90aa7172b0e7c354d4157d4febaf28978df6257e3ddffdb811e404d3713c5f36ec9c6
|
7
|
+
data.tar.gz: 4db3438a11d81744dcfcb2b322e44a245ae254e158160e175ba30c2376686cfa61f6a72fd57d5b6cfb08e73e7ea8b38eba589476d91bb8fc122fac02316f7848
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@ Tzispa
|
|
2
2
|
|
3
3
|
General purpose web framework
|
4
4
|
|
5
|
+
## v0.4.15
|
6
|
+
- move context creation from app to middleware
|
7
|
+
- remove controller/layout custom headers
|
8
|
+
|
9
|
+
|
5
10
|
## v0.4.14
|
6
11
|
- remove moneta session in middleware: now use session goes in App class definition
|
7
12
|
- remove repository dup in context because isn't required without the respository.use method
|
data/lib/tzispa/app.rb
CHANGED
@@ -67,20 +67,12 @@ module Tzispa
|
|
67
67
|
|
68
68
|
def initialize(domain_name)
|
69
69
|
@domain = Domain.new(domain_name)
|
70
|
-
@middleware = Middleware.new self
|
71
70
|
@config = Config::AppConfig.new(@domain).load!
|
71
|
+
@middleware = Middleware.new self
|
72
72
|
end
|
73
73
|
|
74
74
|
def call(env)
|
75
|
-
env
|
76
|
-
env[Tzispa::ENV_TZISPA_CONTEXT] = Tzispa::Http::Context.new(env)
|
77
|
-
begin
|
78
|
-
middleware.call(env)
|
79
|
-
rescue => ex
|
80
|
-
logger.error ex.message
|
81
|
-
env[Tzispa::ENV_TZISPA_CONTEXT].response.status = 500
|
82
|
-
env[Tzispa::ENV_TZISPA_CONTEXT].response.finish
|
83
|
-
end
|
75
|
+
middleware.call(env)
|
84
76
|
end
|
85
77
|
|
86
78
|
def load!
|
@@ -34,8 +34,9 @@ module Tzispa
|
|
34
34
|
status = catch(:halt) {
|
35
35
|
begin
|
36
36
|
send "#{@callmethod}"
|
37
|
-
rescue StandardError, ScriptError =>
|
38
|
-
|
37
|
+
rescue StandardError, ScriptError => ex
|
38
|
+
context.logger.error "#{ex.message} (#{ex.class}):\n #{ex.backtrace.join("\n\t") if ex.respond_to?(:backtrace) && ex.backtrace}"
|
39
|
+
debug_info = debug_info(ex) if config.developing
|
39
40
|
500
|
40
41
|
end
|
41
42
|
}
|
@@ -16,29 +16,12 @@ module Tzispa
|
|
16
16
|
rig = context.app.engine.layout(name: layout_name, format: layout_format.to_sym)
|
17
17
|
response.body << rig.render(context)
|
18
18
|
content_type layout_format
|
19
|
-
set_layout_headers
|
20
19
|
end
|
21
20
|
|
22
21
|
private
|
23
22
|
|
24
23
|
def layout_name
|
25
|
-
|
26
|
-
config.default_layout
|
27
|
-
else
|
28
|
-
context.layout || config.default_layout
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def set_layout_headers
|
34
|
-
headers = Hash.new
|
35
|
-
if config.cache.layout.enabled
|
36
|
-
headers['Cache-Control'] = config.cache.layout.control
|
37
|
-
if config.cache.layout.expires
|
38
|
-
headers['Expires'] = (Time.now + config.cache.layout.expires).utc.rfc2822
|
39
|
-
end
|
40
|
-
end
|
41
|
-
response.headers.merge!(headers)
|
24
|
+
context.layout || config.default_layout
|
42
25
|
end
|
43
26
|
|
44
27
|
|
data/lib/tzispa/middleware.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
module Tzispa
|
4
4
|
class Middleware
|
5
5
|
|
6
|
-
|
7
6
|
def initialize(app)
|
8
7
|
@stack = []
|
9
8
|
@application = app
|
@@ -25,7 +24,15 @@ module Tzispa
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def call(env)
|
28
|
-
|
27
|
+
begin
|
28
|
+
env[Tzispa::ENV_TZISPA_APP] = @application
|
29
|
+
env[Tzispa::ENV_TZISPA_CONTEXT] = Tzispa::Http::Context.new(env)
|
30
|
+
@builder.call(env)
|
31
|
+
rescue => ex
|
32
|
+
@application.logger.error "#{ex.message} (#{ex.class}):\n #{ex.backtrace&.join("\n\t")}"
|
33
|
+
env[Tzispa::ENV_TZISPA_CONTEXT].response.status = 500
|
34
|
+
env[Tzispa::ENV_TZISPA_CONTEXT].response.finish
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
def use(middleware, *args, &blk)
|
data/lib/tzispa/version.rb
CHANGED