module Orion::Controller::StatusHelpers

Overview

HTTP Status Code Helpers Provides semantic methods for setting HTTP status codes

Usage: get "/not-found" do not_found! end

get "/api/user" do unauthorized! json: {error: "Invalid token"} end

Direct including types

Defined in:

orion/controller/status_helpers.cr

Instance Method Summary

Instance Method Detail

def accepted!(message : String | Nil = nil) #

[View source]
def bad_gateway!(message : String = "Bad Gateway") #

[View source]
def bad_request!(message : String = "Bad Request", *, json = nil) #

4xx Client Errors


[View source]
def conflict!(message : String = "Conflict", *, json = nil) #

[View source]
def created!(message : String | Nil = nil, *, json = nil, location : String | Nil = nil) #

[View source]
def forbidden!(message : String = "Forbidden", *, json = nil) #

[View source]
def found!(location : String) #

[View source]
def gateway_timeout!(message : String = "Gateway Timeout") #

[View source]
def gone!(message : String = "Gone") #

[View source]
def head(status : Int32 | Symbol) #

Head response (status only, no body)


[View source]
def internal_server_error!(message : String = "Internal Server Error", *, json = nil) #

5xx Server Errors


[View source]
def method_not_allowed!(message : String = "Method Not Allowed", allowed_methods : Array(String) | Nil = nil) #

[View source]
def moved_permanently!(location : String) #

3xx Redirection


[View source]
def no_content! #

[View source]
def not_acceptable!(message : String = "Not Acceptable") #

[View source]
def not_found!(message : String = "Not Found", *, json = nil) #

[View source]
def not_implemented!(message : String = "Not Implemented") #

[View source]
def not_modified! #

[View source]
def ok!(message : String | Nil = nil) #

2xx Success


[View source]
def payment_required!(message : String = "Payment Required") #

[View source]
def permanent_redirect!(location : String) #

[View source]
def see_other!(location : String) #

[View source]
def service_unavailable!(message : String = "Service Unavailable", retry_after : Int32 | Nil = nil) #

[View source]
def status(code : Int32) #

Generic status setter


[View source]
def temporary_redirect!(location : String) #

[View source]
def too_many_requests!(message : String = "Too Many Requests", retry_after : Int32 | Nil = nil) #

[View source]
def unauthorized!(message : String = "Unauthorized", *, json = nil, www_authenticate : String | Nil = nil) #

[View source]
def unprocessable_entity!(message : String = "Unprocessable Entity", *, json = nil) #

[View source]