Skip to content

Commit 31e62ae

Browse files
committed
[ruby/hanami] Return json and plaintext from the routes.
1 parent f7401a5 commit 31e62ae

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@
22

33
module HelloWorld
44
class Routes < Hanami::Routes
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
514
get "/db", to: "db.index"
615
get "/json", to: "json.index"
716
get "/updates", to: "updates.index"
8-
get "/plaintext", to: "plaintext.index"
917
get "/queries", to: "queries.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
1027
end
1128
end

0 commit comments

Comments
 (0)