Compare commits

..

No commits in common. "ccac1cf651aaa9937f3b01651a96003f33a398b3" and "dc548fcb8389a152caee5a4a23678cad00ac616c" have entirely different histories.

10 changed files with 54 additions and 29 deletions

View file

@ -1,5 +1,5 @@
# This configuration file was generated by `ameba --gen-config` # This configuration file was generated by `ameba --gen-config`
# on 2019-08-25 09:29:24 UTC using Ameba version 0.10.0. # on 2019-06-14 15:05:57 UTC using Ameba version 0.10.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base. # one by one as the reported problems are removed from the code base.
@ -11,3 +11,32 @@ Lint/UselessAssign:
Severity: Warning Severity: Warning
Excluded: Excluded:
- spec/view_spec.cr - spec/view_spec.cr
# Problems found: 1
# Run `ameba --only Lint/ShadowingOuterLocalVar` for details
Lint/ShadowingOuterLocalVar:
Description: Disallows the usage of the same name as outer local variables for block
or proc arguments.
Enabled: true
Severity: Warning
Excluded:
- spec/run_spec.cr
# Problems found: 1
# Run `ameba --only Style/NegatedConditionsInUnless` for details
Style/NegatedConditionsInUnless:
Description: Disallows negated conditions in unless
Enabled: true
Severity: Convention
Excluded:
- src/kemal/ext/response.cr
# Problems found: 1
# Run `ameba --only Metrics/CyclomaticComplexity` for details
Metrics/CyclomaticComplexity:
Description: Disallows methods with a cyclomatic complexity higher than `MaxComplexity`
MaxComplexity: 10
Enabled: true
Severity: Convention
Excluded:
- src/kemal/static_file_handler.cr

View file

@ -1,11 +1,3 @@
# 0.26.1 (01-12-2019)
- Fix process request when a response already closed [#550](https://github.com/kemalcr/kemal/pull/550). Thanks @mamantoha :pray:
- Switch to new Ameba repository [#549](https://github.com/kemalcr/kemal/pull/549). Thanks @mamantoha :pray:
- Check for `KEMAL_ENV` variable already in `Config#initialize`[#552](https://github.com/kemalcr/kemal/pull/552). Thanks @Sija :pray:
- Cleanup Ameba warnings [#551](https://github.com/kemalcr/kemal/pull/551). Thanks @Sija :pray:
- Flush io buffer after each write to log [#554](https://github.com/kemalcr/kemal/pull/554). Thanks @mang :pray:
# 0.26.0 (05-08-2019) # 0.26.0 (05-08-2019)
- Crystal 0.30.0 support :tada: [#548](https://github.com/kemalcr/kemal/pull/548) and [#544](https://github.com/kemalcr/kemal/pull/544). Thanks @bcardiff and @straight-shoota :pray: - Crystal 0.30.0 support :tada: [#548](https://github.com/kemalcr/kemal/pull/548) and [#544](https://github.com/kemalcr/kemal/pull/544). Thanks @bcardiff and @straight-shoota :pray:

View file

@ -1,5 +1,5 @@
name: kemal name: kemal
version: 0.26.1 version: 0.26.0
authors: authors:
- Serdar Dogruyol <dogruyolserdar@gmail.com> - Serdar Dogruyol <dogruyolserdar@gmail.com>

View file

@ -70,7 +70,7 @@ describe "Macros" do
halt env, status_code: 400, response: "Missing origin." halt env, status_code: 400, response: "Missing origin."
end end
get "/" do |_env| get "/" do |env|
"Hello world" "Hello world"
end end

View file

@ -6,10 +6,12 @@ private def run(code)
#{code} #{code}
CR CR
String.build do |stdout| String.build do |stdout|
stderr = String.build do |io| stderr = String.build do |stderr|
Process.new("crystal", ["eval"], input: IO::Memory.new(code), output: stdout, error: io).wait Process.new("crystal", ["eval"], input: IO::Memory.new(code), output: stdout, error: stderr).wait
end
unless stderr.empty?
fail(stderr)
end end
fail(stderr) unless stderr.empty?
end end
end end

View file

@ -8,6 +8,7 @@ module Kemal
@key_file = "" @key_file = ""
@cert_file = "" @cert_file = ""
@config = Kemal.config @config = Kemal.config
read_env
if args if args
parse args parse args
end end
@ -41,15 +42,21 @@ module Kemal
private def configure_ssl private def configure_ssl
{% if !flag?(:without_openssl) %} {% if !flag?(:without_openssl) %}
if @ssl_enabled if @ssl_enabled
abort "SSL Key Not Found" if !@key_file abort "SSL Key Not Found" if !@key_file
abort "SSL Certificate Not Found" if !@cert_file abort "SSL Certificate Not Found" if !@cert_file
ssl = Kemal::SSL.new ssl = Kemal::SSL.new
ssl.key_file = @key_file.not_nil! ssl.key_file = @key_file.not_nil!
ssl.cert_file = @cert_file.not_nil! ssl.cert_file = @cert_file.not_nil!
Kemal.config.ssl = ssl.context Kemal.config.ssl = ssl.context
end end
{% end %} {% end %}
end
private def read_env
if kemal_env = ENV["KEMAL_ENV"]?
@config.env = kemal_env
end
end end
end end
end end

View file

@ -29,7 +29,7 @@ module Kemal
def initialize def initialize
@host_binding = "0.0.0.0" @host_binding = "0.0.0.0"
@port = 3000 @port = 3000
@env = ENV["KEMAL_ENV"]? || "development" @env = "development"
@serve_static = {"dir_listing" => false, "gzip" => true} @serve_static = {"dir_listing" => false, "gzip" => true}
@public_folder = "./public" @public_folder = "./public"
@logging = true @logging = true

View file

@ -1,7 +1,6 @@
class HTTP::Server::Response class HTTP::Server::Response
class Output class Output
def close def close
# ameba:disable Style/NegatedConditionsInUnless
unless response.wrote_headers? && !response.headers.has_key?("Content-Range") unless response.wrote_headers? && !response.headers.has_key?("Content-Range")
response.content_length = @out_count response.content_length = @out_count
end end

View file

@ -8,14 +8,11 @@ module Kemal
elapsed_time = Time.measure { call_next(context) } elapsed_time = Time.measure { call_next(context) }
elapsed_text = elapsed_text(elapsed_time) elapsed_text = elapsed_text(elapsed_time)
@io << Time.utc << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n' @io << Time.utc << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n'
@io.flush
context context
end end
def write(message : String) def write(message : String)
@io << message @io << message
@io.flush
@io
end end
private def elapsed_text(elapsed) private def elapsed_text(elapsed)

View file

@ -4,7 +4,6 @@
module Kemal module Kemal
class StaticFileHandler < HTTP::StaticFileHandler class StaticFileHandler < HTTP::StaticFileHandler
# ameba:disable Metrics/CyclomaticComplexity
def call(context : HTTP::Server::Context) def call(context : HTTP::Server::Context)
return call_next(context) if context.request.path.not_nil! == "/" return call_next(context) if context.request.path.not_nil! == "/"