diff --git a/README.md b/README.md index 10a4fe0..2baa780 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,9 @@ In Kemal, a route is an HTTP method paired with a URL-matching pattern. Each rou end ``` -## Context +## Environment -Accessing the request environment (query params, body, headers e.g) is super easy. You can use the context returned from the block: +Accessing the environment (query params, body, content_type, headers, status_code) is super easy. You can use the environment returned from the block: ```ruby # Matches /hello/kemal @@ -79,18 +79,19 @@ Accessing the request environment (query params, body, headers e.g) is super eas width = env.params["width"] height = env.params["height"] end -``` -## Content Type -Kemal uses *text/html* as the default content type. You can change it via the context. - -```ruby # Set the content as application/json and return JSON get "/user.json" do |env| kemal = {name: "Kemal", language: "Crystal"} - env.set_content_type "application/json" + env.content_type = "application/json" kemal.to_json end + + # Add headers to your response + get "/headers" do |env| + env.add_header "Accept-Language", "tr" + env.add_header "Authorization", "Token 12345" + end ``` ## Thanks