lib/zold/node/front.rb in zold-0.10.15 vs lib/zold/node/front.rb in zold-0.10.16
- old
+ new
@@ -57,13 +57,19 @@
set :remotes, nil? # to be injected at node.rb
set :copies, nil? # to be injected at node.rb
end
before do
- header = request.env["HTTP-#{Http::SCORE_HEADER}".upcase.tr('-', '_')]
- return unless header
- return if settings.remotes.all.empty?
+ name = "HTTP-#{Http::SCORE_HEADER}".upcase.tr('-', '_')
+ header = request.env[name]
+ unless header
+ settings.log.debug("#{request.url}: HTTP header #{Http::SCORE_HEADER} is absent (#{name})")
+ return
+ end
+ if settings.remotes.all.empty?
+ settings.log.debug("#{request.url}: we are in standalone mode, won't update remotes")
+ end
s = Score.parse_text(header)
error(400, 'The score is invalid') unless s.valid?
error(400, 'The score is weak') if s.strength < Score::STRENGTH && !settings.ignore_score_weakness
if s.value > 3
require_relative '../commands/remote'
@@ -137,15 +143,10 @@
get '/remotes' do
content_type 'application/json'
JSON.pretty_generate(
version: VERSION,
score: score.to_h,
- all: settings.remotes.all.map do |r|
- {
- host: r[:host],
- port: r[:port]
- }
- end
+ all: settings.remotes.all
)
end
get %r{/(?<page>.+\.html)} do
content_type 'text/html'