shard-kemal/samples/json_api.cr

10 lines
265 B
Crystal
Raw Normal View History

2015-10-23 19:25:46 +00:00
require "kemal"
require "json"
2015-10-29 09:49:58 +00:00
# You can easily access the context and set content_type like 'application/json'.
2015-10-23 19:25:46 +00:00
# Look how easy to build a JSON serving API.
get "/" do |env|
env.response.content_type = "application/json"
2015-10-23 19:25:46 +00:00
{name: "Serdar", age: 27}.to_json
end