module Azu::Endpoint(Request, Response)

Overview

An Endpoint is an endpoint that handles incoming HTTP requests for a specific route. In a Azu application, an endpoint is a simple testable object.

This design provides self contained actions that don’t share their context accidentally with other actions. It also prevents gigantic controllers. It has several advantages in terms of testability and control of an endpoint.

module ExampleApp
  class UserEndpoint
    include Azu::Endpoint(UserRequest, UserResponse)
  end
end

Included Modules

Defined in:

azu/handler/endpoint.cr

Instance Method Summary

Instance Method Detail

abstract def call : Response #

When we include Endpoint module, we make our object compliant with Azu Endpoints by implementing the #call, which is a method that accepts no arguments

def call : IndexPage
  IndexPage.new
end

[View source]