Skip to content

Commit

Permalink
Update to crystal 0.26 (#929)
Browse files Browse the repository at this point in the history
* Update to crystal 0.26

* update shard.yml to point to a working shell-table

* Update amber-router to 0.2.0

* updates for granite 0.13

* fix params mashing for crystal 0.26

* refactor SSL for crystal 0.26
  • Loading branch information
robacarp authored Aug 17, 2018
1 parent c46adce commit 3bcdf38
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
6 changes: 3 additions & 3 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets:
dependencies:
amber_router:
github: amberframework/amber-router
version: ~> 0.1.0
version: ~> 0.2.0

cli:
github: mosop/cli
Expand Down Expand Up @@ -51,8 +51,8 @@ dependencies:
version: ~> 2.0.0

shell-table:
github: jwaldrip/shell-table.cr
version: ~> 0.9.2
github: luckyframework/shell-table.cr
commit: 078a04ea58ead5203bb435a3b5fff448ddabaeea

slang:
github: jeromegn/slang
Expand Down
10 changes: 8 additions & 2 deletions src/amber/cli/commands/exec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ module Amber::CLI

class Exec < Command
command_name "exec"
@filename : String = "./tmp/#{Time.now.epoch_ms}_console.cr"
@filelogs : String = @filename.sub("console.cr", "console_result.log")
@filename : String
@filelogs : String

def initialize(__previous, __argv)
@filename = "./tmp/#{Time.now.epoch_ms}_console.cr"
@filelogs = @filename.sub("console.cr", "console_result.log")
super(__previous, __argv)
end

class Options
arg "code", desc: "Crystal code or .cr file to execute within the application scope", default: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<% if @model == "granite" -%>
require "granite/adapter/<%= @database %>"

Granite.settings.database_url = Amber.settings.database_url
Granite::Adapters << Granite::Adapter::<%= @database.capitalize %>.new({name: "<%= @database %>", url: Amber.settings.database_url})
Granite.settings.logger = Amber.settings.logger.dup
Granite.settings.logger.progname = "Granite"

<% else -%>
require "<%= @database == "sqlite" ? "sqlite3" : @database %>"
require "crecto"
Expand Down
2 changes: 1 addition & 1 deletion src/amber/cli/templates/app/shard.yml.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
<% else -%>
granite:
github: amberframework/granite
version: ~> 0.12.1
version: ~> 0.13.0
<% end -%>

quartz_mailer:
Expand Down
8 changes: 7 additions & 1 deletion src/amber/router/params.cr
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ module Amber::Router
params_hash = Types::Params.new
query.each { |key, _| params_hash[key] = query[key] }
form.each { |key, _| params_hash[key] = form[key] }
route.each_key { |key| params_hash[key] = route[key] }

route.each_key do |key|
if value = route[key]
params_hash[key] = value
end
end

json.each_key { |key| params_hash[key] = json[key].to_s }
multipart.each_key { |key| params_hash[key] = multipart[key].to_s }
params_hash
Expand Down
8 changes: 7 additions & 1 deletion src/amber/server/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ module Amber
logger.info "#{version.colorize(:light_cyan)} serving application \"#{settings.name.capitalize}\" at #{host_url.colorize(:light_cyan).mode(:underline)}"
handler.prepare_pipelines
server = HTTP::Server.new(handler)
server.tls = Amber::SSL.new(settings.ssl_key_file.not_nil!, settings.ssl_cert_file.not_nil!).generate_tls if ssl_enabled?

if ssl_enabled?
ssl_config = Amber::SSL.new(settings.ssl_key_file.not_nil!, settings.ssl_cert_file.not_nil!).generate_tls
server.bind_ssl Amber.settings.host, Amber.settings.port, ssl_config

This comment has been minimized.

Copy link
@Sija

Sija Aug 18, 2018

Contributor

That should've been #bind_tls. #bind_ssl is (already) deprecated.

This comment has been minimized.

Copy link
@robacarp

robacarp Aug 18, 2018

Author Member

thanks @Sija

This comment has been minimized.

Copy link
@Sija

Sija Aug 18, 2018

Contributor

Opened #931 containing this change. I've removed it in the end since it requires Crystal.next.

else
server.bind_tcp Amber.settings.host, Amber.settings.port
end

Signal::INT.trap do
Signal::INT.reset
Expand Down

0 comments on commit 3bcdf38

Please sign in to comment.