yaframework 0.4.6 → 0.4.7
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 +4 -0
- data/Gemfile.lock +1 -1
- data/examples/content_types.rb +2 -1
- data/examples/cookies.rb +5 -1
- data/examples/error_handling.rb +3 -3
- data/lib/yaframework/base.rb +4 -6
- data/lib/yaframework/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aec9734b89fbd8a9c87fb63506f49f53df83c0f141efd612d5cdceb9d4d8c64
|
4
|
+
data.tar.gz: 8d43e4889c14798d20400ae36bfa9c6b76797bf7348eac539d85c690dcf250a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00af9a420fd2edffe78d77d6a2ecfc81973cbadb9543424153a6a5e689409a06d4c98a5ff54e7ddbda2a122cbe3bcd2d5b563968f8820738c6f21747269201d7
|
7
|
+
data.tar.gz: ba55916ef3b9776ab8711e82af51406b5d4e00b6991acf04418fc1526f6a0aa803757b9744296180843cf201534f4ed14292ac2f738a92d00bb8d5ad11bf6925
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/examples/content_types.rb
CHANGED
@@ -8,7 +8,8 @@ app.get "/" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
app.get "/html" do
|
11
|
-
response.html "This is <b>HTML</b>, where you cat use some <small>tags</small
|
11
|
+
response.html "This is <b>HTML</b>, where you cat use some <small>tags</small>.
|
12
|
+
<br/>JSON <a href=\"/json\">here</a>,
|
12
13
|
<br/>Plain text <a href=\"/text\">here</a>"
|
13
14
|
end
|
14
15
|
|
data/examples/cookies.rb
CHANGED
@@ -5,8 +5,12 @@ app = Yaframework::Application
|
|
5
5
|
|
6
6
|
app.get "/" do
|
7
7
|
response.set_cookie("foo", "bar")
|
8
|
-
|
8
|
+
"Your cookies, sir: #{response["Set-Cookie"]}.<br/>Go <a href=\"/delete\">here</a> to delete them"
|
9
9
|
end
|
10
10
|
|
11
|
+
app.get "/delete" do
|
12
|
+
response.delete_cookie("foo")
|
13
|
+
"Your cookies, sir: #{response["Set-Cookie"]}"
|
14
|
+
end
|
11
15
|
|
12
16
|
app.listen(4567)
|
data/examples/error_handling.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "../lib/yaframework"
|
4
4
|
app = Yaframework::Application
|
5
5
|
|
6
6
|
app.get "/" do
|
7
|
-
"This is the root, go somewhere else"
|
7
|
+
"This is the root, go somewhere else..<br/>Maybe <a href=\"/asdfg\">here</a>, idk"
|
8
8
|
end
|
9
9
|
|
10
10
|
app.handle 404 do
|
11
|
-
"Hey, I just handled a 404 error!"
|
11
|
+
"Hey, I just handled a 404 error!<br/>The dude from the previous page deceived you!"
|
12
12
|
end
|
13
13
|
|
14
14
|
app.handle 500 do
|
data/lib/yaframework/base.rb
CHANGED
@@ -55,17 +55,15 @@ module Yaframework
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def route_eval
|
58
|
+
route = find_route
|
59
|
+
response.status = 404 unless route
|
60
|
+
|
58
61
|
if @inbox[response.status]
|
59
62
|
response.write instance_eval(&@inbox[response.status])
|
60
63
|
return response.finish
|
61
64
|
end
|
62
65
|
|
63
|
-
route
|
64
|
-
if route
|
65
|
-
response.write instance_eval(&route[:handler])
|
66
|
-
else
|
67
|
-
response.status = 404
|
68
|
-
end
|
66
|
+
response.write instance_eval(&route[:handler]) if route
|
69
67
|
response.finish
|
70
68
|
end
|
71
69
|
|
data/lib/yaframework/version.rb
CHANGED