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