Skip to content

Commit ab904d8

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

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,10 +2,26 @@
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"
6-
get "/json", to: "json.index"
715
get "/updates", to: "updates.index"
8-
get "/plaintext", to: "plaintext.index"
916
get "/queries", to: "queries.index"
17+
get "/plaintext", to: ->(env) do
18+
[200,
19+
{
20+
'Server' => 'Hanami',
21+
'Content-Type' => 'text/plain',
22+
'Date' => Time.now.httpdate
23+
},
24+
['Hello, World!']]
25+
end
1026
end
1127
end

0 commit comments

Comments
 (0)