module
Orion::Controller
Overview
The Orion::Controller module can be included in any struct or class to add
the various helpers methods to make constructing your application easier.
Included Modules
- Orion::Controller::JSONHelpers
- Orion::Controller::ParamHelpers
- Orion::Controller::Rendering
- Orion::Controller::RequestHelpers
- Orion::Controller::ResponseHelpers
- Orion::Controller::StatusHelpers
- Orion::View::CacheHelpers
Defined in:
orion/controller.crorion/controller/json_helpers.cr
orion/controller/param_helpers.cr
orion/controller/request_helpers.cr
orion/controller/status_helpers.cr
Instance Method Summary
-
#context : Server::Context
The http context
-
#websocket : HTTP::WebSocket
The websocket, if the controller was initialized from a
wsroute. -
#websocket? : HTTP::WebSocket | Nil
The websocket, if the controller was initialized from a
wsroute.
Instance methods inherited from module Orion::Controller::JSONHelpers
json(data, status : Int32 = 200)
json,
json_accepted(data)
json_accepted,
json_bad_request(data)
json_bad_request,
json_created(data, location : String | Nil = nil)
json_created,
json_forbidden(data)
json_forbidden,
json_internal_server_error(data)
json_internal_server_error,
json_not_found(data)
json_not_found,
json_ok(data)
json_ok,
json_unauthorized(data)
json_unauthorized,
json_unprocessable_entity(data)
json_unprocessable_entity,
jsonp(data, callback : String = "callback", status : Int32 = 200)
jsonp
Instance methods inherited from module Orion::Controller::ParamHelpers
params : ParamsHash
params
Instance methods inherited from module Orion::Controller::StatusHelpers
accepted!(message : String | Nil = nil)
accepted!,
bad_gateway!(message : String = "Bad Gateway")
bad_gateway!,
bad_request!(message : String = "Bad Request", *, json = nil)
bad_request!,
conflict!(message : String = "Conflict", *, json = nil)
conflict!,
created!(message : String | Nil = nil, *, json = nil, location : String | Nil = nil)
created!,
forbidden!(message : String = "Forbidden", *, json = nil)
forbidden!,
found!(location : String)
found!,
gateway_timeout!(message : String = "Gateway Timeout")
gateway_timeout!,
gone!(message : String = "Gone")
gone!,
head(status : Int32 | Symbol)
head,
internal_server_error!(message : String = "Internal Server Error", *, json = nil)
internal_server_error!,
method_not_allowed!(message : String = "Method Not Allowed", allowed_methods : Array(String) | Nil = nil)
method_not_allowed!,
moved_permanently!(location : String)
moved_permanently!,
no_content!
no_content!,
not_acceptable!(message : String = "Not Acceptable")
not_acceptable!,
not_found!(message : String = "Not Found", *, json = nil)
not_found!,
not_implemented!(message : String = "Not Implemented")
not_implemented!,
not_modified!
not_modified!,
ok!(message : String | Nil = nil)
ok!,
payment_required!(message : String = "Payment Required")
payment_required!,
permanent_redirect!(location : String)
permanent_redirect!,
see_other!(location : String)
see_other!,
service_unavailable!(message : String = "Service Unavailable", retry_after : Int32 | Nil = nil)
service_unavailable!,
status(code : Int32)
status,
temporary_redirect!(location : String)
temporary_redirect!,
too_many_requests!(message : String = "Too Many Requests", retry_after : Int32 | Nil = nil)
too_many_requests!,
unauthorized!(message : String = "Unauthorized", *, json = nil, www_authenticate : String | Nil = nil)
unauthorized!,
unprocessable_entity!(message : String = "Unprocessable Entity", *, json = nil)
unprocessable_entity!
Macros inherited from module Orion::View::CacheHelpers
cache(object, &block)
cache,
cache_if(condition, object, &block)
cache_if
Instance methods inherited from module Orion::Controller::ResponseHelpers
content_type=(content_type)
content_type=,
response
response,
status=(status)
status=,
status_code=(status_code)
status_code=
Instance methods inherited from module Orion::Controller::RequestHelpers
format
format,
formats
formats,
host
host,
hostname
hostname,
path_params
path_params,
query_params
query_params,
remote_address
remote_address,
request
request,
resource
resource
Macros inherited from module Orion::Controller::Rendering
render(*, json)render(*, text, content_type = "text/plain") render
Macros inherited from module Orion::View
layout(filename, *, locals = NamedTuple.new)
layout,
render(*, view = @def.name, layout = true, locals = NamedTuple.new, layout_locals = nil)
render,
view_helper(mod)view_helper(&block) view_helper
Instance Method Detail
def websocket? : HTTP::WebSocket | Nil
#
The websocket, if the controller was initialized from a ws route.