adding payload

master
Izimic 2020-11-26 16:15:04 +01:00
parent b6b52c632a
commit cbebead2aa
1 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,6 @@
require "http/server" require "http/server"
require "option_parser" require "option_parser"
require "./payload.cr"
VERSION = 0.1 VERSION = 0.1
port = 3000 port = 3000
@ -22,12 +23,13 @@ OptionParser.parse do |parser|
end end
server = HTTP::Server.new do |context| server = HTTP::Server.new do |context|
pp context.request
if context.request.method != "POST" || context.request.path != "/" if context.request.method != "POST" || context.request.path != "/"
context.response.status = HTTP::Status::NOT_FOUND context.response.status = HTTP::Status::NOT_FOUND
else else
payload = Payload.new(context.request)
context.response.content_type = "text/plain" context.response.content_type = "text/plain"
context.response.print "Hello world! The time is #{Time.local}" context.response.print payload.to_json
end end
end end