shard-kemal/samples/json_api.cr
Stephan Nordnes Eriksen 9e95ea7ea0 Updating json sample
There is a new syntax for this now. You need to write env.response.content_type
2016-01-29 12:31:00 +01:00

10 lines
265 B
Crystal

require "kemal"
require "json"
# You can easily access the context and set content_type like 'application/json'.
# Look how easy to build a JSON serving API.
get "/" do |env|
env.response.content_type = "application/json"
{name: "Serdar", age: 27}.to_json
end