mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Added JSON payload retrieval to README
This commit is contained in:
parent
cb36a38488
commit
bbe22e96e3
1 changed files with 10 additions and 0 deletions
10
README.md
10
README.md
|
@ -81,6 +81,16 @@ Accessing the environment (query params, body, content_type, headers, status_cod
|
|||
height = env.params["height"]
|
||||
end
|
||||
|
||||
# Easily access JSON payload from the params.
|
||||
# The request content type needs to be application/json
|
||||
# The payload
|
||||
# {"name": "Serdar", "likes": ["Ruby", "Crystal"]}
|
||||
post "/json_params" do |env|
|
||||
name = env.params["name"] as String
|
||||
likes = env.params["likes"] as Array
|
||||
"#{name} likes #{likes.each.join(',')}"
|
||||
end
|
||||
|
||||
# Set the content as application/json and return JSON
|
||||
get "/user.json" do |env|
|
||||
kemal = {name: "Kemal", language: "Crystal"}
|
||||
|
|
Loading…
Reference in a new issue