Hello World
This recipe will help you to setup a Hello World! response in your /hello path.
First you need an amber project generated with Amber CLI or from scratch.
First create a src/controllers/hello_controller.cr file and add this:
src/controllers/hello_controller.cr
1
class HelloController < ApplicationController
2
def hello
3
"Hello Amber!"
4
end
5
end
Copied!
Then add a new route in your config/routes.cr file:
1
Amber::Server.configure do |app|
2
pipeline :web do
3
# pipelines...
4
end
5
6
routes :web do
7
# other routes,,,
8
get "/hello", HelloController, :hello
9
end
10
end
Copied!
Last modified 3yr ago
Copy link