module

Marten::Handlers::Schema::Callbacks

Provides the ability to define schema validation callbacks.

This module provides the ability to define callbacks that are executed before, after, after success or/and after failed validation of a schema. They allow to intercept the incoming request and to return early HTTP responses. Four hooks are enabled by the use of this module:

  • before_schema_validation callbacks are executed before the validation of the schema
  • after_schema_validation callbacks are executed right after the validation of the schema
  • after_successful_schema_validation callbacks are executed right after the validation but only if the schema is valid
  • after_failed_schema_validation callbacks are executed right after the validation but only if the schema is not valid

Macros

after_failed_schema_validation(*names)

Allows to define callbacks that are called after a failed schema validation.

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 right away.

Source
after_schema_validation(*names)

Allows to define callbacks that are called after validating the schema (whether it's valid or not).

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 right away.

Source
after_successful_schema_validation(*names)

Allows to define callbacks that are called after a successful schema validation.

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 right away.

Source
before_schema_validation(*names)

Allows to define callbacks that are called before validating the schema.

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 right away.

Source