class Amber::Controller::Base

Overview

Patch the Base controller to include Schema integration

Included Modules

Direct Known Subclasses

Defined in:

amber/controller/base.cr
amber/controller/schema_integration.cr

Constructors

Instance Method Summary

Macros inherited from module Amber::DSL::Callbacks

after_action after_action, before_action before_action

Instance methods inherited from module Amber::Controller::Helpers::MarkdownHelper

render_markdown(source : String, options : Amber::Markdown::Options = Amber::Markdown::Options.new) : String
render_markdown(*, file : String, options : Amber::Markdown::Options = Amber::Markdown::Options.new) : String
render_markdown

Instance methods inherited from module Amber::Controller::Helpers::AssetHelpers

favicon_tag(path : String = "/favicon.ico") : String favicon_tag, image_tag(src : String, **attrs) : String image_tag, javascript_include_tag(path : String, **attrs) : String javascript_include_tag, stylesheet_link_tag(path : String, **attrs) : String stylesheet_link_tag

Instance methods inherited from module Amber::Controller::Helpers::URLHelpers

button_to(text : String, url : String, method : String = "POST", **attrs) : String button_to, link_back(text : String = "Back", **attrs) : String link_back, link_to(text : String, url : String, **attrs) : String link_to, mail_to(email : String, text : String | Nil = nil, **attrs) : String mail_to

Instance methods inherited from module Amber::Controller::Helpers::FormHelpers

checkbox(name : String, checked : Bool = false, **attrs) : String checkbox, email_field(name : String, value : String | Nil = nil, **attrs) : String email_field, form_for(action : String, method : String = "POST", **attrs, &block : -> String) : String form_for, hidden_field(name : String, value : String) : String hidden_field, label(for_field : String, text : String | Nil = nil, **attrs) : String label, number_field(name : String, value : Number | Nil = nil, **attrs) : String number_field, password_field(name : String, **attrs) : String password_field, radio_button(name : String, value : String, checked : Bool = false, **attrs) : String radio_button, select_field(name : String, options : Array, selected : String | Nil = nil, **attrs) : String select_field, submit_button(text : String = "Submit", **attrs) : String submit_button, text_area(name : String, value : String | Nil = nil, **attrs) : String text_area, text_field(name : String, value : String | Nil = nil, **attrs) : String text_field

Instance methods inherited from module Amber::Controller::Helpers::NumberHelpers

number_to_currency(number : Number, unit : String = "$", precision : Int32 = 2) : String number_to_currency, number_to_human_size(bytes : Number) : String number_to_human_size, number_to_percentage(number : Number, precision : Int32 = 1) : String number_to_percentage, number_with_delimiter(number : Number, delimiter : String = ",") : String number_with_delimiter

Instance methods inherited from module Amber::Controller::Helpers::TextHelpers

escape_html(text : String) : String escape_html, highlight(text : String, phrase : String, tag : String = "mark") : String highlight, pluralize(count : Int32, singular : String, plural : String | Nil = nil) : String pluralize, simple_format(text : String) : String simple_format, strip_tags(html : String) : String strip_tags, truncate(text : String, length : Int32 = 30, omission : String = "...") : String truncate, word_wrap(text : String, line_width : Int32 = 80) : String word_wrap

Instance methods inherited from module Amber::Controller::Helpers::TagHelpers

content_tag(tag_name : String, content : String | Nil = nil, **attrs, &block : -> String) : String
content_tag(tag_name : String, content : String | Nil = nil, **attrs) : String
content_tag
, tag(tag_name : String, **attrs) : String tag

Instance methods inherited from module Amber::Controller::Helpers::I18n

l(*arg) l, t(*arg) t

Instance methods inherited from module Amber::Controller::Helpers::Route

action_name action_name, controller_name controller_name, controller_name_no_underscore controller_name_no_underscore, route_resource route_resource, route_scope route_scope

Instance methods inherited from module Amber::Controller::Helpers::Responders

set_response(body, status_code = 200, content_type = Content::TYPE[:html]) set_response

Macros inherited from module Amber::Controller::Helpers::Render

render(template = nil, layout = true, partial = nil, path = "src/views", folder = __FILE__) render

Instance methods inherited from module Amber::Controller::Helpers::Redirect

redirect_back(**args) redirect_back, redirect_to(controller : Symbol | Class, action : Symbol, **args)
redirect_to(location : String, **args)
redirect_to(action : Symbol, **args)
redirect_to

Instance methods inherited from module Amber::Controller::Helpers::CSRF

csrf_metatag csrf_metatag, csrf_tag csrf_tag, csrf_token csrf_token

Instance methods inherited from module Amber::Schema::ControllerIntegration

render_validated(data : Hash(String, JSON::Any), status : Int32 = 200) render_validated, respond_with(data : Hash(String, JSON::Any) | NamedTuple | Nil = nil, status : Int32 = 200, schema_name : String | Nil = nil) respond_with, respond_with_error(message : String, status : Int32 = 400, code : String | Nil = nil) respond_with_error, respond_with_errors(errors : Array(Amber::Schema::Error), status : Int32 = 422) respond_with_errors, validate_request(schema_name : String | Nil = nil) : Amber::Schema::LegacyResult validate_request, validate_response(data : Hash(String, JSON::Any), status : Int32 = 200, schema_name : String | Nil = nil) : Amber::Schema::LegacyResult validate_response, validated_params : Hash(String, JSON::Any) | Nil validated_params, validation_failed? : Bool validation_failed?

Macros inherited from module Amber::Schema::ControllerIntegration

auto_validate auto_validate, response_schema(action, &block) response_schema, schema(action, &block) schema, validate_schema(action = nil, required = true) validate_schema

Constructor Detail

def self.new(context : HTTP::Server::Context) #

[View source]

Instance Method Detail

def client_ip(*args, **options) #

[View source]
def client_ip(*args, **options, &) #

[View source]
def cookies(*args, **options) #

[View source]
def cookies(*args, **options, &) #

[View source]
def delete?(*args, **options) #

[View source]
def delete?(*args, **options, &) #

[View source]
def filters : Filters #

def filters=(filters : Filters) #

def flash(*args, **options) #

[View source]
def flash(*args, **options, &) #

[View source]
def format(*args, **options) #

[View source]
def format(*args, **options, &) #

[View source]
def get?(*args, **options) #

[View source]
def get?(*args, **options, &) #

[View source]
def halt!(*args, **options) #

[View source]
def halt!(*args, **options, &) #

[View source]
def head?(*args, **options) #

[View source]
def head?(*args, **options, &) #

[View source]
def patch?(*args, **options) #

[View source]
def patch?(*args, **options, &) #

[View source]
def port(*args, **options) #

[View source]
def port(*args, **options, &) #

[View source]
def post?(*args, **options) #

[View source]
def post?(*args, **options, &) #

[View source]
def put?(*args, **options) #

[View source]
def put?(*args, **options, &) #

[View source]
def request(*args, **options) #

[View source]
def request(*args, **options, &) #

[View source]
def request_data : Hash(String, JSON::Any) | Nil #

Instance property to store validated request data


def request_data=(request_data : Hash(String, JSON::Any) | Nil) #

Instance property to store validated request data


def requested_url(*args, **options) #

[View source]
def requested_url(*args, **options, &) #

[View source]
def response(*args, **options) #

[View source]
def response(*args, **options, &) #

[View source]
def route(*args, **options) #

[View source]
def route(*args, **options, &) #

[View source]
def route_path(name : Symbol, **params) : String #

Named route path helper - generates a path string for the given named route.


[View source]
def route_url(name : Symbol, **params) : String #

Named route URL helper - generates a full URL for the given named route.


[View source]
def run_after_filter(action) #

[View source]
def run_before_filter(action) #

TODO Find a way to make these protected again.


[View source]
def session(*args, **options) #

[View source]
def session(*args, **options, &) #

[View source]
def validation_result : Amber::Schema::LegacyResult | Nil #

Store validation result


def validation_result=(validation_result : Amber::Schema::LegacyResult | Nil) #

Store validation result


def valve(*args, **options) #

[View source]
def valve(*args, **options, &) #

[View source]
def websocket?(*args, **options) #

[View source]
def websocket?(*args, **options, &) #

[View source]