From db48f40fe6be0bce3b18fdd9ff2b7d6a43f1b44b Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Fri, 13 Nov 2015 21:23:05 +0200 Subject: [PATCH] Added middleware section to README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index a0cdc78..a00bac9 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,21 @@ Accessing the environment (query params, body, content_type, headers, status_cod end ``` +## Middlewares + +You can create your own middlewares by inheriting from ```HTTP::Handler``` + +```crystal +class CustomHandler < HTTP::Handler + def call(request) + puts "Doing some custom stuff here" + call_next request + end +end + +Kemal.config.add_handler CustomHandler.new +``` + ## Static Files Kemal has built-in support for serving your static files. You need to put your static files under your ```/public``` directory.