I was playing with some JSON based REST APIs, and I was starting to get tired of typing JSON3.read(response.body)
all the time, so I came up with the following layer.
julia> module HTTPJSON3
import HTTP, JSON3
function json3_layer(handler)
return function(req; kw...)
HTTP.setheader(req, "Content-Type" => "application/json")
r = handler(req; kw...)
HTTP.Response(r.status, r.headers, JSON3.read(r.body); r.request)
end
end
function HTTP.Messages.bodysummary(obj::Union{JSON3.Object, JSON3.Array})
io = IOBuffer()
print(io, obj)
String(take!(io))
end
HTTP.@client [json3_layer]
end
Is there a package that already does something like this for me?