module Marten::Handlers::Callbacks

Overview

Provides the ability to define handler callbacks.

This module provides the ability to define callbacks that are executed before and / or after dispatching the considered handlers. They allow to intercept the incoming request and to return early HTTP responses. Two hooks are enabled by the use of this module: before_dispatch callbacks are executed before the execution of the handler's #dispatch method while after_dispatch callbacks are executed after it.

Direct including types

Defined in:

marten/handlers/concerns/callbacks.cr

Macro Summary

Macro Detail

macro after_dispatch(*names) #

Allows to do define callbacks that are called after executing Marten::Handler#dispatch.

Those callbacks have access to the incoming #request object and they can return a custom HTTP response. If one of such callbacks returns a custom HTTP response, the following callbacks will be skipped and this custom response will be returned by the handler instead of the one returned by the #dispatch method.


[View source]
macro before_dispatch(*names) #

Allows to do define callbacks that are called before executing Marten::Handler#dispatch.

Those callbacks have access to the incoming #request object and they can return early response. If one of such callbacks returns an early response, the following callbacks will be skipped, as well as the handler's #dispatch method.


[View source]