Skip to content

Commit 3c5b37f

Browse files
committed
[ruby/hanami] Return json and plaintext from the routes.
1 parent d4acac6 commit 3c5b37f

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

frameworks/Ruby/hanami/app/actions/json/index.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

frameworks/Ruby/hanami/app/actions/plaintext/index.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

frameworks/Ruby/hanami/config/routes.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22

33
module HelloWorld
44
class Routes < Hanami::Routes
5-
get "/json", to: "json.index"
5+
get "/json", to: ->(env) do
6+
[200,
7+
{
8+
'Server' => 'Rails',
9+
'Content-Type' => 'application/json',
10+
'Date' => Time.now.httpdate,
11+
},
12+
[{ 'message' => 'Hello, World!' }.to_json]]
13+
end
614
get "/db", to: "db.index"
715
get "/queries", to: "queries.index"
816
get "/fortunes", to: "fortunes.index"
917
get "/updates", to: "updates.index"
10-
get "/plaintext", to: "plaintext.index"
18+
get "/plaintext", to: ->(env) do
19+
[200,
20+
{
21+
'Server' => 'Hanami',
22+
'Content-Type' => 'text/plain',
23+
'Date' => Time.now.httpdate
24+
},
25+
['Hello, World!']]
26+
end
1127
end
1228
end

0 commit comments

Comments
 (0)