Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Luna 2021-03-31 22:36:00 -03:00
commit 6af6569b0f
8 changed files with 61 additions and 27 deletions

41
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: CI
on:
push:
pull_request:
schedule:
- cron: "0 3 * * 1" # Every monday at 3 AM
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
crystal: [latest, nightly]
runs-on: ${{ matrix.os }}
steps:
- name: Install Crystal
uses: oprypin/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}
- name: Download source
uses: actions/checkout@v2
- name: Install dependencies
run: shards install
env:
SHARDS_OPTS: --ignore-crystal-version
- name: Run specs
run: |
crystal spec
crystal spec --release --no-debug
- name: Check formatting
run: crystal tool format --check
- name: Run ameba linter
run: bin/ameba

View File

@ -1,14 +0,0 @@
language: crystal
crystal:
- latest
- nightly
script:
- crystal spec
- crystal spec --release --no-debug
- crystal tool format --check
- bin/ameba src
matrix:
allow_failures:
- crystal: nightly

View File

@ -1,3 +1,10 @@
# 1.0.0 (??-03-2021)
- Crystal 1.0.0 support :tada:
- Update Radix to use latest 0.4.0 [#596](https://github.com/kemalcr/kemal/pull/596). Thanks @luislavena :pray:
- Use latest version of Ameba dependency (dev) [#597](https://github.com/kemalcr/kemal/pull/597). Thanks @luislavena :pray:
- Fix StaticFileHandler failing spec [#599](https://github.com/kemalcr/kemal/pull/599). Thanks @jinn999 :pray:
# 0.27.0 (28-11-2020)
- Crystal 0.35.x support :tada: Thanks @bcardiff :pray:

View File

@ -5,7 +5,7 @@
Lightning Fast, Super Simple web framework.
[![Build Status](https://travis-ci.org/kemalcr/kemal.svg?branch=master)](https://travis-ci.org/kemalcr/kemal)
[![CI](https://github.com/kemalcr/kemal/actions/workflows/ci.yml/badge.svg)](https://github.com/kemalcr/kemal/actions/workflows/ci.yml)
[![Join the chat at https://gitter.im/sdogruyol/kemal](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sdogruyol/kemal?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Super Simple ⚡️

View File

@ -1,5 +1,5 @@
name: kemal
version: 0.27.0
version: 1.0.0
authors:
- Serdar Dogruyol <dogruyolserdar@gmail.com>
@ -7,7 +7,7 @@ authors:
dependencies:
radix:
github: luislavena/radix
version: ~> 0.3.8
version: ~> 0.4.0
kilt:
github: jeromegn/kilt
version: ~> 0.4.0
@ -18,8 +18,8 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 0.12.0
version: ~> 0.14.0
crystal: 0.35.0
crystal: ">= 0.36.0"
license: MIT

View File

@ -1,6 +1,6 @@
require "./spec_helper"
private def handle(request, fallthrough = true)
private def handle(request, fallthrough = true, decompress = true)
io = IO::Memory.new
response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response)
@ -8,7 +8,7 @@ private def handle(request, fallthrough = true)
handler.call context
response.close
io.rewind
HTTP::Client::Response.from_io(io)
HTTP::Client::Response.from_io(io, decompress: decompress)
end
describe Kemal::StaticFileHandler do
@ -51,7 +51,7 @@ describe Kemal::StaticFileHandler do
it "should gzip a file if config is true, headers accept gzip and file is > 880 bytes" do
serve_static({"gzip" => true, "dir_listing" => true})
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"}
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers)
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers), decompress: false
response.status_code.should eq(200)
response.headers["Content-Encoding"].should eq "gzip"
end
@ -59,7 +59,7 @@ describe Kemal::StaticFileHandler do
it "should not gzip a file if config is true, headers accept gzip and file is < 880 bytes" do
serve_static({"gzip" => true, "dir_listing" => true})
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"}
response = handle HTTP::Request.new("GET", "/dir/test.txt", headers)
response = handle HTTP::Request.new("GET", "/dir/test.txt", headers), decompress: false
response.status_code.should eq(200)
response.headers["Content-Encoding"]?.should be_nil
end
@ -67,7 +67,7 @@ describe Kemal::StaticFileHandler do
it "should not gzip a file if config is false, headers accept gzip and file is > 880 bytes" do
serve_static({"gzip" => false, "dir_listing" => true})
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"}
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers)
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers), decompress: false
response.status_code.should eq(200)
response.headers["Content-Encoding"]?.should be_nil
end

View File

@ -22,8 +22,8 @@ describe "Kemal::WebSocketHandler" do
it "matches on given route" do
handler = Kemal::WebSocketHandler::INSTANCE
ws "/" { |socket| socket.send("Match") }
ws "/no_match" { |socket| socket.send "No Match" }
ws("/", &.send("Match"))
ws("/no_match", &.send("No Match"))
headers = HTTP::Headers{
"Upgrade" => "websocket",
"Connection" => "Upgrade",

View File

@ -66,7 +66,7 @@ module Kemal
end
def self.display_startup_message(config, server)
addresses = server.addresses.map { |address| "#{config.scheme}://#{address}" }.join ", "
addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" }
log "[#{config.env}] Kemal is ready to lead at #{addresses}"
end