From a36596d3322ea398de5510eba2d756255fb65163 Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Sun, 27 Dec 2015 12:05:19 +0200 Subject: [PATCH] Update middlewares doc --- docs/middlewares.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/middlewares.md b/docs/middlewares.md index 048556e..9a17a21 100644 --- a/docs/middlewares.md +++ b/docs/middlewares.md @@ -1,6 +1,28 @@ # Middlewares -You can create your own middlewares by inheriting from ```HTTP::Handler``` +## Built-in Middlewares + +Kemal has built-in middlewares for common use cases. + +### HTTP Basic Authorization + +This middleware let's you add HTTP Basic Authorization support to your Kemal application. +To increase easy of use you can use this middleware with `basic_auth` macro like below. + +```crystal +require "kemal" + +basic_auth "username", "password" + +get "/" do + "This won't render without correct username and password." +end + +``` + +## Custom middlewares + +You can create your own middleware by inheriting from ```HTTP::Handler``` ```crystal class CustomHandler < HTTP::Handler