From 211685ee7407e23b7579394c0ac499ff518b6e19 Mon Sep 17 00:00:00 2001 From: sdogruyol Date: Thu, 31 Dec 2015 14:03:11 +0200 Subject: [PATCH] Fix basic_auth --- src/kemal/macros.cr | 2 +- src/kemal/param_parser.cr | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kemal/macros.cr b/src/kemal/macros.cr index 1ae818b..05e857f 100644 --- a/src/kemal/macros.cr +++ b/src/kemal/macros.cr @@ -23,7 +23,7 @@ end # Uses Kemal::Middleware::HTTPBasicAuth to easily add HTTP Basic Auth support. macro basic_auth(username, password) - auth_handler = Kemal::Middleware::HTTPBasicAuth.new("serdar", "123") + auth_handler = Kemal::Middleware::HTTPBasicAuth.new(username, password) Kemal.config.add_handler auth_handler end diff --git a/src/kemal/param_parser.cr b/src/kemal/param_parser.cr index 4d1458b..26a013b 100644 --- a/src/kemal/param_parser.cr +++ b/src/kemal/param_parser.cr @@ -37,6 +37,10 @@ class Kemal::ParamParser parse_part(@request.query) end + # Parses JSON request body if Content-Type is `application/json`. + # If request body is a JSON Hash then all the params are parsed and added into `params`. + # If request body is a JSON Array it's added into `params` as `_json` and can be accessed + # like params["_json"] def parse_json return unless @request.body && @request.headers["Content-Type"]? == APPLICATION_JSON