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) #

def bad_gateway!(message : String = "Bad Gateway") #

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

4xx Client Errors


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

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

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

def found!(location : String) #

def gateway_timeout!(message : String = "Gateway Timeout") #

def gone!(message : String = "Gone") #

def head(status : Int32 | Symbol) #

Head response (status only, no body)


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

5xx Server Errors


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

def moved_permanently!(location : String) #

3xx Redirection


def no_content! #

def not_acceptable!(message : String = "Not Acceptable") #

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

def not_implemented!(message : String = "Not Implemented") #

def not_modified! #

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

2xx Success


def payment_required!(message : String = "Payment Required") #

def permanent_redirect!(location : String) #

def see_other!(location : String) #

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

def status(code : Int32) #

Generic status setter


def temporary_redirect!(location : String) #

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

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

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