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 + +```