Testing functions in crystal. Had to commit the template because it was outdated

This commit is contained in:
2023-06-01 09:44:33 -03:00
parent 0045b432b4
commit f2be91d628
9 changed files with 127 additions and 1 deletions

21
tapas2/handler.cr Normal file
View File

@ -0,0 +1,21 @@
require "http/request"
require "http/headers"
class Handler
def run(request : HTTP::Request)
if request.body.nil?
return {
body: "Foo",
status_code: 200,
headers: HTTP::Headers{"Content-Type" => "text/plain"},
}
end
{
body: "Hello, Crystal. You said: #{request.body.try(&.gets_to_end)}",
status_code: 200,
headers: HTTP::Headers{"Content-Type" => "text/plain"},
}
end
end

2
tapas2/shard.yml Normal file
View File

@ -0,0 +1,2 @@
name: crystal-http-template
version: 0.1.0