tzispa 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/tzispa/app.rb +5 -13
- data/lib/tzispa/controller/base.rb +11 -3
- data/lib/tzispa/http/context.rb +6 -7
- data/lib/tzispa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b3b6df11ce0ea41a4e564ec835dd8c98a87218c
|
4
|
+
data.tar.gz: 951f7c1e75d68514481c2f81cc5c92d461834bd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 031c851c6926cabb3ee2e8f2283b3701d842eba3fd9d607a75b5cfb39604a3acff2d9e9402905063ba6ffd65874c48373fd62eb41b04f22c2ad8ae58cfb930cc
|
7
|
+
data.tar.gz: cd1a9dd768e7723b1ae6f50fe3d8a3b63ba8e523aae1dc827e83cc14543dd9755dbc958c3fcf8ca8bf26aca4b8acc3ae7efb36ca24fb9c9af80d84cce7c31fb4
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@ Tzispa
|
|
2
2
|
|
3
3
|
General purpose web framework
|
4
4
|
|
5
|
+
## v0.4.11
|
6
|
+
- Rescue exceptions and catch halts on controller/base
|
7
|
+
- http/context error_500 not sets response.status
|
8
|
+
- Rescue exceptions in app.call only log and set response.status previous code moved to controller/base
|
9
|
+
|
5
10
|
## v0.4.10
|
6
11
|
- http/context api method return a canonical url including hostname
|
7
12
|
|
data/lib/tzispa/app.rb
CHANGED
@@ -8,7 +8,6 @@ require 'tzispa/routes'
|
|
8
8
|
require 'tzispa/config/appconfig'
|
9
9
|
require 'tzispa/middleware'
|
10
10
|
require 'tzispa/http/context'
|
11
|
-
require 'tzispa/helpers/error_view'
|
12
11
|
require 'tzispa_data'
|
13
12
|
require "tzispa_rig"
|
14
13
|
|
@@ -22,8 +21,6 @@ module Tzispa
|
|
22
21
|
class Application
|
23
22
|
extend Forwardable
|
24
23
|
|
25
|
-
include Tzispa::Helpers::ErrorView
|
26
|
-
|
27
24
|
attr_reader :domain, :config, :middleware, :repository, :engine, :logger
|
28
25
|
def_delegator :@middleware, :use
|
29
26
|
def_delegator :@domain, :name
|
@@ -76,18 +73,13 @@ module Tzispa
|
|
76
73
|
|
77
74
|
def call(env)
|
78
75
|
env[Tzispa::ENV_TZISPA_APP] = self
|
79
|
-
|
80
|
-
env[Tzispa::ENV_TZISPA_CONTEXT] = context
|
76
|
+
env[Tzispa::ENV_TZISPA_CONTEXT] = Tzispa::Http::Context.new(env)
|
81
77
|
begin
|
82
78
|
middleware.call(env)
|
83
|
-
rescue
|
84
|
-
logger.error
|
85
|
-
|
86
|
-
|
87
|
-
else
|
88
|
-
context.error_500 error_page(domain)
|
89
|
-
end
|
90
|
-
context.response.finish
|
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
|
91
83
|
end
|
92
84
|
end
|
93
85
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'forwardable'
|
4
4
|
require 'tzispa/version'
|
5
5
|
require 'tzispa/rig/template'
|
6
|
+
require 'tzispa/helpers/error_view'
|
6
7
|
|
7
8
|
|
8
9
|
module Tzispa
|
@@ -11,6 +12,8 @@ module Tzispa
|
|
11
12
|
class Base
|
12
13
|
extend Forwardable
|
13
14
|
|
15
|
+
include Tzispa::Helpers::ErrorView
|
16
|
+
|
14
17
|
attr_reader :context
|
15
18
|
def_delegators :@context, :request, :response, :config
|
16
19
|
|
@@ -28,13 +31,18 @@ module Tzispa
|
|
28
31
|
|
29
32
|
def invoke(callmethod)
|
30
33
|
status = catch(:halt) {
|
31
|
-
|
34
|
+
begin
|
35
|
+
send "#{@callmethod}"
|
36
|
+
rescue StandardError, ScriptError => exx
|
37
|
+
context.error_500( config.developing ? debug_info(exx) : nil )
|
38
|
+
end
|
32
39
|
}
|
33
40
|
response.status = status if status.is_a?(Integer)
|
34
|
-
|
41
|
+
if (response.client_error? || response.server_error?) && !config.developing
|
42
|
+
response.body = error_page(context.domain)
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
|
-
|
38
46
|
end
|
39
47
|
|
40
48
|
end
|
data/lib/tzispa/http/context.rb
CHANGED
@@ -38,13 +38,6 @@ module Tzispa
|
|
38
38
|
router_params&.fetch(:layout, nil)
|
39
39
|
end
|
40
40
|
|
41
|
-
def error_500(body)
|
42
|
-
500.tap { |code|
|
43
|
-
response.status = code
|
44
|
-
response.body = body
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
41
|
def set_last_access
|
49
42
|
session[SESSION_LAST_ACCESS] = Time.now.utc.iso8601
|
50
43
|
end
|
@@ -73,6 +66,12 @@ module Tzispa
|
|
73
66
|
session.delete(SESSION_AUTH_USER)
|
74
67
|
end
|
75
68
|
|
69
|
+
def error_500(str)
|
70
|
+
500.tap { |code|
|
71
|
+
response.body = str if str
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
76
75
|
def path(path_id, params={})
|
77
76
|
app.class.routes.path path_id, params
|
78
77
|
end
|
data/lib/tzispa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|