Scope

Scope defines a prefix for routes which will be nested in a block.

class DemoController < Grip::Controllers::Http
  def get(context : Context) : Context
    context
      .json(nil)
  end
end

class Application < Grip::Application
  def initialize
    super(environment: "development", serve_static: false)

    # The route gets built from the ground starting from the lowest GET /, to the top /api/v1.
    scope "/api/v1" do
      get "/", DemoController

      scope "/users" do
        get "/", DemoController
      end
    end
  end
end