Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 803 Bytes

hello-world.md

File metadata and controls

39 lines (29 loc) · 803 Bytes

Hello World

This recipe will help you to setup a Hello World! response in your /hello path.

{% hint style="warning" %} First you need an amber project generated with Amber CLI or from scratch. {% endhint %}

First create a src/controllers/hello_controller.cr file and add this:

{% code-tabs %} {% code-tabs-item title="src/controllers/hello_controller.cr" %}

class HelloController < ApplicationController
  def hello
    "Hello Amber!"
  end
end

{% endcode-tabs-item %} {% endcode-tabs %}

Then add a new route in your config/routes.cr file:

Amber::Server.configure do |app|
  pipeline :web do
    # pipelines...
  end

  routes :web do
    # other routes,,,
    get "/hello", HelloController, :hello
  end
end