Currently, response bodies mix trailing newline and no trailing newline, and it kind of works because bin/ubi is written in Ruby and uses IO#puts, which will automatically add a newline if the string being printed does not end with a newline. However, other languages may not have similar behavior, and for consistency, it is best if the server always uses newlines in cli responses.
19 lines
558 B
Ruby
19 lines
558 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Clover
|
|
hash_branch("cli") do |r|
|
|
r.post api? do
|
|
response["content-type"] = "text/plain"
|
|
|
|
unless (argv = r.POST["argv"]).is_a?(Array) && argv.all?(String)
|
|
response.status = 400
|
|
next "! Invalid request: No or invalid argv parameter provided\n"
|
|
end
|
|
|
|
project_id = env["clover.project_id"] = ApiKey.where(id: rodauth.session["pat_id"]).get(:project_id)
|
|
env["clover.project_ubid"] = UBID.from_uuidish(project_id).to_s
|
|
r.halt UbiCli.process(argv, env)
|
|
end
|
|
end
|
|
end
|