Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
A simple wrapper around HTTP::Server for building CORS-enabled, multi-threaded HTTP micro-services in Crystal.
Add this to your application's shard.yml
:
dependencies:
tiny:
github: molovo/tiny
require "tiny"
# Create the handler for incoming requests
serve do |request, response|
# This block will only be run on GET requests
request.get do
response.json({
"message" => "The server is up and running",
"timestamp" => Time.now.to_s,
})
end
# This block will only be run on POST requests
request.post do
# Do something awesome!
end
end