mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-31 01:38:31 +00:00
Implement fields handling
This commit is contained in:
parent
1b78001201
commit
8855978e5b
@ -97,6 +97,16 @@ class APIHandler < Kemal::Handler
|
|||||||
if env.response.headers["Content-Type"]?.try &.== "application/json"
|
if env.response.headers["Content-Type"]?.try &.== "application/json"
|
||||||
response = JSON.parse(response)
|
response = JSON.parse(response)
|
||||||
|
|
||||||
|
if env.params.query["fields"]?
|
||||||
|
fields_text = env.params.query["fields"]
|
||||||
|
begin
|
||||||
|
JSONFilter.filter(response, fields_text)
|
||||||
|
rescue ex
|
||||||
|
env.response.status_code = 400
|
||||||
|
response = {"error" => ex.message}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if env.params.query["pretty"]? && env.params.query["pretty"] == "1"
|
if env.params.query["pretty"]? && env.params.query["pretty"] == "1"
|
||||||
response = response.to_pretty_json
|
response = response.to_pretty_json
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user