Added json_api sample

This commit is contained in:
Sdogruyol 2015-10-23 22:25:46 +03:00
parent 328629b6f4
commit d0c87f23d1
2 changed files with 18 additions and 1 deletions

9
samples/json_api.cr Normal file
View file

@ -0,0 +1,9 @@
require "kemal"
require "json"
# You can easily access the environment 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