From 6c1dd90611ff5ec2c7ff2deafa0a8de415c94bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Fri, 4 Dec 2015 13:54:12 +0200 Subject: [PATCH] Create json.md --- docs/json.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/json.md diff --git a/docs/json.md b/docs/json.md new file mode 100644 index 0000000..1b0090e --- /dev/null +++ b/docs/json.md @@ -0,0 +1,16 @@ +# Serving JSON API + +Just use `to_json` method to return. + +```ruby +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.content_type = "application/json" + {name: "Serdar", age: 27}.to_json +end + +```