Fix basic_auth

This commit is contained in:
sdogruyol 2015-12-31 14:03:11 +02:00
parent 2c95fa560d
commit 211685ee74
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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