tzispa 0.4.14 → 0.4.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dbc5a8880088d5b4e2f801186d577aeea706fed
4
- data.tar.gz: 83c80d45fd7f12cca9832410af722dc7255e216e
3
+ metadata.gz: 1cb6d1509d41c50ba037726c1873f83f1a8b3ab2
4
+ data.tar.gz: c31027f97f9e020a1374fe41701fa765df5718b1
5
5
  SHA512:
6
- metadata.gz: 190fa40ab88227a0e00a42d0dc2cd5b9bfcb667245aa357e283d6ff9c7fc49bdfaf19fc73afad72f48cacaefbf9cdac4d9e46b6f8ecd6bee1b09beff9730ab54
7
- data.tar.gz: ef6d2b834082dae6fc230b3fe21225faf76cafd085c45996ad712eb63cce9753221e69046bf3a1b55952f0f7a677d410de39aa575c5ce41d6a77fd08ff012e7e
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[Tzispa::ENV_TZISPA_APP] = self
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 => exx
38
- debug_info = debug_info(exx) if config.developing
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
- if config.auth_required && !context.logged? && context.layout
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
 
@@ -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
- @builder.call(env)
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)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tzispa
4
- VERSION = '0.4.14'
4
+ VERSION = '0.4.15'
5
5
  FRAMEWORK_NAME = 'Tzispa'
6
6
  GEM_NAME = 'tzispa'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzispa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Antonio Piñero