I'm a newbie to Crystal-lang.
I'm trying the Http Server example given in the crystal-lang docs.
require "http/server"
server = HTTP::Server.new(8080) do |context|
context.response.content_type = "text/plain"
context.response.print "Hello world! The time is #{Time.now}"
end
puts "Listening on http://127.0.0.1:8080"
server.listen
When I run this code I'm getting the following error.
Error in httpserv.cr:3: no overload matches 'HTTP::Server.new' with type Int32
Overloads are:
- HTTP::Server.new(handlers : Array(HTTP::Handler), &handler)
- HTTP::Server.new(&handler)
- HTTP::Server.new(handlers : Array(HTTP::Handler))
- HTTP::Server.new(handler : HTTP::Handler | HTTP::Handler::Proc)
server = HTTP::Server.new(8080) do |context|
What I can gather from this is I need to specify some methods/functions for handling the HTTP requests, but I'm not getting how to do that.
What is the correct way to do that is my question?
Thanks in advance.