Module: ApiHammer::HaltMethods
- Included in:
- Rails, Sinatra::Halt
- Defined in:
- lib/api_hammer/halt_methods.rb
Instance Method Summary collapse
-
#find_or_halt(model, find_attrs, options = {}) ⇒ Object
attempts to find and return the given model (an ActiveRecord::Base subclass) with the given attributes.
-
#halt_accepted(body, render_options = {}) ⇒ Object
halt with status 202 Accepted, responding with the given body object.
-
#halt_already_reported(body, render_options = {}) ⇒ Object
halt with status 208 Already Reported, responding with the given body object.
-
#halt_authentication_timeout(errors, render_options = {}) ⇒ Object
halt with status 419 Authentication Timeout, responding with the given errors object on the 'errors' key.
-
#halt_bad_gateway(errors, render_options = {}) ⇒ Object
halt with status 502 Bad Gateway, responding with the given errors object on the 'errors' key.
-
#halt_bad_request(errors, render_options = {}) ⇒ Object
halt with status 400 Bad Request, responding with the given errors object on the 'errors' key.
-
#halt_bandwidth_limit_exceeded(errors, render_options = {}) ⇒ Object
halt with status 509 Bandwidth Limit Exceeded, responding with the given errors object on the 'errors' key.
-
#halt_conflict(errors, render_options = {}) ⇒ Object
halt with status 409 Conflict, responding with the given errors object on the 'errors' key.
-
#halt_created(body, render_options = {}) ⇒ Object
halt with status 201 Created, responding with the given body object.
-
#halt_error(status, errors, options = {}) ⇒ Object
halt and render the given errors in the body on the 'errors' key.
-
#halt_expectation_failed(errors, render_options = {}) ⇒ Object
halt with status 417 Expectation Failed, responding with the given errors object on the 'errors' key.
-
#halt_failed_dependency(errors, render_options = {}) ⇒ Object
halt with status 424 Failed Dependency, responding with the given errors object on the 'errors' key.
-
#halt_forbidden(errors, render_options = {}) ⇒ Object
halt with status 403 Forbidden, responding with the given errors object on the 'errors' key.
-
#halt_found(body, render_options = {}) ⇒ Object
halt with status 302 Found, responding with the given body object.
-
#halt_gateway_timeout(errors, render_options = {}) ⇒ Object
halt with status 504 Gateway Timeout, responding with the given errors object on the 'errors' key.
-
#halt_gone(errors, render_options = {}) ⇒ Object
halt with status 410 Gone, responding with the given errors object on the 'errors' key.
-
#halt_http_version_not_supported(errors, render_options = {}) ⇒ Object
halt with status 505 HTTP Version Not Supported, responding with the given errors object on the 'errors' key.
-
#halt_im_a_teapot(errors, render_options = {}) ⇒ Object
halt with status 418 I'm a teapot, responding with the given errors object on the 'errors' key.
-
#halt_im_used(body, render_options = {}) ⇒ Object
halt with status 226 IM Used, responding with the given body object.
-
#halt_insufficient_storage(errors, render_options = {}) ⇒ Object
halt with status 507 Insufficient Storage, responding with the given errors object on the 'errors' key.
-
#halt_internal_server_error(errors, render_options = {}) ⇒ Object
halt with status 500 Internal Server Error, responding with the given errors object on the 'errors' key.
-
#halt_length_required(errors, render_options = {}) ⇒ Object
halt with status 411 Length Required, responding with the given errors object on the 'errors' key.
-
#halt_locked(errors, render_options = {}) ⇒ Object
halt with status 423 Locked, responding with the given errors object on the 'errors' key.
-
#halt_loop_detected(errors, render_options = {}) ⇒ Object
halt with status 508 Loop Detected, responding with the given errors object on the 'errors' key.
-
#halt_method_not_allowed(errors, render_options = {}) ⇒ Object
halt with status 405 Method Not Allowed, responding with the given errors object on the 'errors' key.
-
#halt_moved_permanently(body, render_options = {}) ⇒ Object
halt with status 301 Moved Permanently, responding with the given body object.
-
#halt_multi_status(body, render_options = {}) ⇒ Object
halt with status 207 Multi-Status, responding with the given body object.
-
#halt_multiple_choices(body, render_options = {}) ⇒ Object
halt with status 300 Multiple Choices, responding with the given body object.
-
#halt_network_authentication_required(errors, render_options = {}) ⇒ Object
halt with status 511 Network Authentication Required, responding with the given errors object on the 'errors' key.
-
#halt_no_content(render_options = {}) ⇒ Object
halt with status 204 No Content.
-
#halt_no_response(errors, render_options = {}) ⇒ Object
halt with status 444 No Response, responding with the given errors object on the 'errors' key.
-
#halt_non_authoritative_information(body, render_options = {}) ⇒ Object
halt with status 203 Non-Authoritative Information, responding with the given body object.
-
#halt_not_acceptable(errors, render_options = {}) ⇒ Object
halt with status 406 Not Acceptable, responding with the given errors object on the 'errors' key.
-
#halt_not_extended(errors, render_options = {}) ⇒ Object
halt with status 510 Not Extended, responding with the given errors object on the 'errors' key.
-
#halt_not_found(errors, render_options = {}) ⇒ Object
halt with status 404 Not Found, responding with the given errors object on the 'errors' key.
-
#halt_not_implemented(errors, render_options = {}) ⇒ Object
halt with status 501 Not Implemented, responding with the given errors object on the 'errors' key.
-
#halt_not_modified(render_options = {}) ⇒ Object
halt with status 304 Not Modified.
-
#halt_ok(body, render_options = {}) ⇒ Object
halt with status 200 OK, responding with the given body object.
-
#halt_partial_content(body, render_options = {}) ⇒ Object
halt with status 206 Partial Content, responding with the given body object.
-
#halt_payment_required(errors, render_options = {}) ⇒ Object
halt with status 402 Payment Required, responding with the given errors object on the 'errors' key.
-
#halt_permanent_redirect(body, render_options = {}) ⇒ Object
halt with status 308 Permanent Redirect, responding with the given body object.
-
#halt_precondition_failed(errors, render_options = {}) ⇒ Object
halt with status 412 Precondition Failed, responding with the given errors object on the 'errors' key.
-
#halt_precondition_required(errors, render_options = {}) ⇒ Object
halt with status 428 Precondition Required, responding with the given errors object on the 'errors' key.
-
#halt_proxy_authentication_required(errors, render_options = {}) ⇒ Object
halt with status 407 Proxy Authentication Required, responding with the given errors object on the 'errors' key.
-
#halt_redirect(errors, render_options = {}) ⇒ Object
halt with status 451 Redirect, responding with the given errors object on the 'errors' key.
-
#halt_request_entity_too_large(errors, render_options = {}) ⇒ Object
halt with status 413 Request Entity Too Large, responding with the given errors object on the 'errors' key.
-
#halt_request_header_fields_too_large(errors, render_options = {}) ⇒ Object
halt with status 431 Request Header Fields Too Large, responding with the given errors object on the 'errors' key.
-
#halt_request_timeout(errors, render_options = {}) ⇒ Object
halt with status 408 Request Timeout, responding with the given errors object on the 'errors' key.
-
#halt_request_uri_too_long(errors, render_options = {}) ⇒ Object
halt with status 414 Request-URI Too Long, responding with the given errors object on the 'errors' key.
-
#halt_requested_range_not_satisfiable(errors, render_options = {}) ⇒ Object
halt with status 416 Requested Range Not Satisfiable, responding with the given errors object on the 'errors' key.
-
#halt_reset_content(render_options = {}) ⇒ Object
halt with status 205 Reset Content.
-
#halt_see_other(body, render_options = {}) ⇒ Object
halt with status 303 See Other, responding with the given body object.
-
#halt_service_unavailable(errors, render_options = {}) ⇒ Object
halt with status 503 Service Unavailable, responding with the given errors object on the 'errors' key.
-
#halt_temporary_redirect(body, render_options = {}) ⇒ Object
halt with status 307 Temporary Redirect, responding with the given body object.
-
#halt_too_many_requests(errors, render_options = {}) ⇒ Object
halt with status 429 Too Many Requests, responding with the given errors object on the 'errors' key.
-
#halt_unauthorized(errors, render_options = {}) ⇒ Object
halt with status 401 Unauthorized, responding with the given errors object on the 'errors' key.
-
#halt_unavailable_for_legal_reasons(errors, render_options = {}) ⇒ Object
halt with status 451 Unavailable For Legal Reasons, responding with the given errors object on the 'errors' key.
-
#halt_unordered_collection(errors, render_options = {}) ⇒ Object
halt with status 425 Unordered Collection, responding with the given errors object on the 'errors' key.
-
#halt_unprocessable_entity(errors, render_options = {}) ⇒ Object
halt with status 422 Unprocessable Entity, responding with the given errors object on the 'errors' key.
-
#halt_unsupported_media_type(errors, render_options = {}) ⇒ Object
halt with status 415 Unsupported Media Type, responding with the given errors object on the 'errors' key.
-
#halt_upgrade_required(errors, render_options = {}) ⇒ Object
halt with status 426 Upgrade Required, responding with the given errors object on the 'errors' key.
-
#halt_use_proxy(body, render_options = {}) ⇒ Object
halt with status 305 Use Proxy, responding with the given body object.
-
#halt_variant_also_negotiates(errors, render_options = {}) ⇒ Object
halt with status 506 Variant Also Negotiates, responding with the given errors object on the 'errors' key.
Instance Method Details
#find_or_halt(model, find_attrs, options = {}) ⇒ Object
attempts to find and return the given model (an ActiveRecord::Base subclass) with the given attributes. halts with 404 (does not return) if that fails. options[:status] may specify a different status if that is required.
e.g.:
find_or_halt(User, :email => '[email protected]')
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/api_hammer/halt_methods.rb', line 45 def find_or_halt(model, find_attrs, ={}) = {:status => 404}.merge() record = model.where(find_attrs).first unless record attributes = find_attrs.map { |attr, val| "#{attr}: #{val}" }.join(", ") model_name = model.table_name model_name = model_name.singularize if model_name.respond_to?(:singularize) = I18n.t(:"errors.unknown_record_with_attributes", :default => "Unknown %{model_name}! %{attributes}", :model_name => model_name, :attributes => attributes ) halt_error([:status], {model_name => []}) end record end |
#halt_accepted(body, render_options = {}) ⇒ Object
halt with status 202 Accepted, responding with the given body object
72 73 74 |
# File 'lib/api_hammer/halt_methods.rb', line 72 def halt_accepted(body, = {}) halt(202, body, ) end |
#halt_already_reported(body, render_options = {}) ⇒ Object
halt with status 208 Already Reported, responding with the given body object
102 103 104 |
# File 'lib/api_hammer/halt_methods.rb', line 102 def halt_already_reported(body, = {}) halt(208, body, ) end |
#halt_authentication_timeout(errors, render_options = {}) ⇒ Object
halt with status 419 Authentication Timeout, responding with the given errors object on the 'errors' key
247 248 249 |
# File 'lib/api_hammer/halt_methods.rb', line 247 def halt_authentication_timeout(errors, = {}) halt_error(419, errors, ) end |
#halt_bad_gateway(errors, render_options = {}) ⇒ Object
halt with status 502 Bad Gateway, responding with the given errors object on the 'errors' key
317 318 319 |
# File 'lib/api_hammer/halt_methods.rb', line 317 def halt_bad_gateway(errors, = {}) halt_error(502, errors, ) end |
#halt_bad_request(errors, render_options = {}) ⇒ Object
halt with status 400 Bad Request, responding with the given errors object on the 'errors' key
152 153 154 |
# File 'lib/api_hammer/halt_methods.rb', line 152 def halt_bad_request(errors, = {}) halt_error(400, errors, ) end |
#halt_bandwidth_limit_exceeded(errors, render_options = {}) ⇒ Object
halt with status 509 Bandwidth Limit Exceeded, responding with the given errors object on the 'errors' key
352 353 354 |
# File 'lib/api_hammer/halt_methods.rb', line 352 def halt_bandwidth_limit_exceeded(errors, = {}) halt_error(509, errors, ) end |
#halt_conflict(errors, render_options = {}) ⇒ Object
halt with status 409 Conflict, responding with the given errors object on the 'errors' key
197 198 199 |
# File 'lib/api_hammer/halt_methods.rb', line 197 def halt_conflict(errors, = {}) halt_error(409, errors, ) end |
#halt_created(body, render_options = {}) ⇒ Object
halt with status 201 Created, responding with the given body object
67 68 69 |
# File 'lib/api_hammer/halt_methods.rb', line 67 def halt_created(body, = {}) halt(201, body, ) end |
#halt_error(status, errors, options = {}) ⇒ Object
halt and render the given errors in the body on the 'errors' key
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/api_hammer/halt_methods.rb', line 4 def halt_error(status, errors, = {}) errors_as_json = errors.respond_to?(:as_json) ? errors.as_json : errors unless errors_as_json.is_a?(Hash) raise ArgumentError, "errors be an object representable in JSON as a Hash; got errors = #{errors.inspect}" end unless errors_as_json.keys.all? { |k| k.is_a?(String) || k.is_a?(Symbol) } raise ArgumentError, "errors keys must all be string or symbol; got errors = #{errors.inspect}" end unless errors_as_json.values.all? { |v| v.is_a?(Array) && v.all? { |e| e.is_a?(String) } } raise ArgumentError, "errors values must all be arrays of strings; got errors = #{errors.inspect}" end = nil = .reject do |k,v| (k.to_s == 'error_message').tap do || if = v end end end body = {'errors' => errors} ||= begin error_values = errors.values.inject([], &:+) if error_values.size <= 1 error_values.first else # sentencify with periods error_values.map { |v| v =~ /\.\s*\z/ ? v : v + '.' }.join(' ') end end body['error_message'] = if halt(status, body, ) end |
#halt_expectation_failed(errors, render_options = {}) ⇒ Object
halt with status 417 Expectation Failed, responding with the given errors object on the 'errors' key
237 238 239 |
# File 'lib/api_hammer/halt_methods.rb', line 237 def halt_expectation_failed(errors, = {}) halt_error(417, errors, ) end |
#halt_failed_dependency(errors, render_options = {}) ⇒ Object
halt with status 424 Failed Dependency, responding with the given errors object on the 'errors' key
262 263 264 |
# File 'lib/api_hammer/halt_methods.rb', line 262 def halt_failed_dependency(errors, = {}) halt_error(424, errors, ) end |
#halt_forbidden(errors, render_options = {}) ⇒ Object
halt with status 403 Forbidden, responding with the given errors object on the 'errors' key
167 168 169 |
# File 'lib/api_hammer/halt_methods.rb', line 167 def halt_forbidden(errors, = {}) halt_error(403, errors, ) end |
#halt_found(body, render_options = {}) ⇒ Object
halt with status 302 Found, responding with the given body object
122 123 124 |
# File 'lib/api_hammer/halt_methods.rb', line 122 def halt_found(body, = {}) halt(302, body, ) end |
#halt_gateway_timeout(errors, render_options = {}) ⇒ Object
halt with status 504 Gateway Timeout, responding with the given errors object on the 'errors' key
327 328 329 |
# File 'lib/api_hammer/halt_methods.rb', line 327 def halt_gateway_timeout(errors, = {}) halt_error(504, errors, ) end |
#halt_gone(errors, render_options = {}) ⇒ Object
halt with status 410 Gone, responding with the given errors object on the 'errors' key
202 203 204 |
# File 'lib/api_hammer/halt_methods.rb', line 202 def halt_gone(errors, = {}) halt_error(410, errors, ) end |
#halt_http_version_not_supported(errors, render_options = {}) ⇒ Object
halt with status 505 HTTP Version Not Supported, responding with the given errors object on the 'errors' key
332 333 334 |
# File 'lib/api_hammer/halt_methods.rb', line 332 def halt_http_version_not_supported(errors, = {}) halt_error(505, errors, ) end |
#halt_im_a_teapot(errors, render_options = {}) ⇒ Object
halt with status 418 I'm a teapot, responding with the given errors object on the 'errors' key
242 243 244 |
# File 'lib/api_hammer/halt_methods.rb', line 242 def halt_im_a_teapot(errors, = {}) halt_error(418, errors, ) end |
#halt_im_used(body, render_options = {}) ⇒ Object
halt with status 226 IM Used, responding with the given body object
107 108 109 |
# File 'lib/api_hammer/halt_methods.rb', line 107 def halt_im_used(body, = {}) halt(226, body, ) end |
#halt_insufficient_storage(errors, render_options = {}) ⇒ Object
halt with status 507 Insufficient Storage, responding with the given errors object on the 'errors' key
342 343 344 |
# File 'lib/api_hammer/halt_methods.rb', line 342 def halt_insufficient_storage(errors, = {}) halt_error(507, errors, ) end |
#halt_internal_server_error(errors, render_options = {}) ⇒ Object
halt with status 500 Internal Server Error, responding with the given errors object on the 'errors' key
307 308 309 |
# File 'lib/api_hammer/halt_methods.rb', line 307 def halt_internal_server_error(errors, = {}) halt_error(500, errors, ) end |
#halt_length_required(errors, render_options = {}) ⇒ Object
halt with status 411 Length Required, responding with the given errors object on the 'errors' key
207 208 209 |
# File 'lib/api_hammer/halt_methods.rb', line 207 def halt_length_required(errors, = {}) halt_error(411, errors, ) end |
#halt_locked(errors, render_options = {}) ⇒ Object
halt with status 423 Locked, responding with the given errors object on the 'errors' key
257 258 259 |
# File 'lib/api_hammer/halt_methods.rb', line 257 def halt_locked(errors, = {}) halt_error(423, errors, ) end |
#halt_loop_detected(errors, render_options = {}) ⇒ Object
halt with status 508 Loop Detected, responding with the given errors object on the 'errors' key
347 348 349 |
# File 'lib/api_hammer/halt_methods.rb', line 347 def halt_loop_detected(errors, = {}) halt_error(508, errors, ) end |
#halt_method_not_allowed(errors, render_options = {}) ⇒ Object
halt with status 405 Method Not Allowed, responding with the given errors object on the 'errors' key
177 178 179 |
# File 'lib/api_hammer/halt_methods.rb', line 177 def halt_method_not_allowed(errors, = {}) halt_error(405, errors, ) end |
#halt_moved_permanently(body, render_options = {}) ⇒ Object
halt with status 301 Moved Permanently, responding with the given body object
117 118 119 |
# File 'lib/api_hammer/halt_methods.rb', line 117 def halt_moved_permanently(body, = {}) halt(301, body, ) end |
#halt_multi_status(body, render_options = {}) ⇒ Object
halt with status 207 Multi-Status, responding with the given body object
97 98 99 |
# File 'lib/api_hammer/halt_methods.rb', line 97 def halt_multi_status(body, = {}) halt(207, body, ) end |
#halt_multiple_choices(body, render_options = {}) ⇒ Object
halt with status 300 Multiple Choices, responding with the given body object
112 113 114 |
# File 'lib/api_hammer/halt_methods.rb', line 112 def halt_multiple_choices(body, = {}) halt(300, body, ) end |
#halt_network_authentication_required(errors, render_options = {}) ⇒ Object
halt with status 511 Network Authentication Required, responding with the given errors object on the 'errors' key
362 363 364 |
# File 'lib/api_hammer/halt_methods.rb', line 362 def halt_network_authentication_required(errors, = {}) halt_error(511, errors, ) end |
#halt_no_content(render_options = {}) ⇒ Object
halt with status 204 No Content
82 83 84 |
# File 'lib/api_hammer/halt_methods.rb', line 82 def halt_no_content( = {}) halt(204, '', ) end |
#halt_no_response(errors, render_options = {}) ⇒ Object
halt with status 444 No Response, responding with the given errors object on the 'errors' key
292 293 294 |
# File 'lib/api_hammer/halt_methods.rb', line 292 def halt_no_response(errors, = {}) halt_error(444, errors, ) end |
#halt_non_authoritative_information(body, render_options = {}) ⇒ Object
halt with status 203 Non-Authoritative Information, responding with the given body object
77 78 79 |
# File 'lib/api_hammer/halt_methods.rb', line 77 def (body, = {}) halt(203, body, ) end |
#halt_not_acceptable(errors, render_options = {}) ⇒ Object
halt with status 406 Not Acceptable, responding with the given errors object on the 'errors' key
182 183 184 |
# File 'lib/api_hammer/halt_methods.rb', line 182 def halt_not_acceptable(errors, = {}) halt_error(406, errors, ) end |
#halt_not_extended(errors, render_options = {}) ⇒ Object
halt with status 510 Not Extended, responding with the given errors object on the 'errors' key
357 358 359 |
# File 'lib/api_hammer/halt_methods.rb', line 357 def halt_not_extended(errors, = {}) halt_error(510, errors, ) end |
#halt_not_found(errors, render_options = {}) ⇒ Object
halt with status 404 Not Found, responding with the given errors object on the 'errors' key
172 173 174 |
# File 'lib/api_hammer/halt_methods.rb', line 172 def halt_not_found(errors, = {}) halt_error(404, errors, ) end |
#halt_not_implemented(errors, render_options = {}) ⇒ Object
halt with status 501 Not Implemented, responding with the given errors object on the 'errors' key
312 313 314 |
# File 'lib/api_hammer/halt_methods.rb', line 312 def halt_not_implemented(errors, = {}) halt_error(501, errors, ) end |
#halt_not_modified(render_options = {}) ⇒ Object
halt with status 304 Not Modified
132 133 134 |
# File 'lib/api_hammer/halt_methods.rb', line 132 def halt_not_modified( = {}) halt(304, '', ) end |
#halt_ok(body, render_options = {}) ⇒ Object
halt with status 200 OK, responding with the given body object
62 63 64 |
# File 'lib/api_hammer/halt_methods.rb', line 62 def halt_ok(body, = {}) halt(200, body, ) end |
#halt_partial_content(body, render_options = {}) ⇒ Object
halt with status 206 Partial Content, responding with the given body object
92 93 94 |
# File 'lib/api_hammer/halt_methods.rb', line 92 def halt_partial_content(body, = {}) halt(206, body, ) end |
#halt_payment_required(errors, render_options = {}) ⇒ Object
halt with status 402 Payment Required, responding with the given errors object on the 'errors' key
162 163 164 |
# File 'lib/api_hammer/halt_methods.rb', line 162 def halt_payment_required(errors, = {}) halt_error(402, errors, ) end |
#halt_permanent_redirect(body, render_options = {}) ⇒ Object
halt with status 308 Permanent Redirect, responding with the given body object
147 148 149 |
# File 'lib/api_hammer/halt_methods.rb', line 147 def halt_permanent_redirect(body, = {}) halt(308, body, ) end |
#halt_precondition_failed(errors, render_options = {}) ⇒ Object
halt with status 412 Precondition Failed, responding with the given errors object on the 'errors' key
212 213 214 |
# File 'lib/api_hammer/halt_methods.rb', line 212 def halt_precondition_failed(errors, = {}) halt_error(412, errors, ) end |
#halt_precondition_required(errors, render_options = {}) ⇒ Object
halt with status 428 Precondition Required, responding with the given errors object on the 'errors' key
277 278 279 |
# File 'lib/api_hammer/halt_methods.rb', line 277 def halt_precondition_required(errors, = {}) halt_error(428, errors, ) end |
#halt_proxy_authentication_required(errors, render_options = {}) ⇒ Object
halt with status 407 Proxy Authentication Required, responding with the given errors object on the 'errors' key
187 188 189 |
# File 'lib/api_hammer/halt_methods.rb', line 187 def halt_proxy_authentication_required(errors, = {}) halt_error(407, errors, ) end |
#halt_redirect(errors, render_options = {}) ⇒ Object
halt with status 451 Redirect, responding with the given errors object on the 'errors' key
302 303 304 |
# File 'lib/api_hammer/halt_methods.rb', line 302 def halt_redirect(errors, = {}) halt_error(451, errors, ) end |
#halt_request_entity_too_large(errors, render_options = {}) ⇒ Object
halt with status 413 Request Entity Too Large, responding with the given errors object on the 'errors' key
217 218 219 |
# File 'lib/api_hammer/halt_methods.rb', line 217 def halt_request_entity_too_large(errors, = {}) halt_error(413, errors, ) end |
#halt_request_header_fields_too_large(errors, render_options = {}) ⇒ Object
halt with status 431 Request Header Fields Too Large, responding with the given errors object on the 'errors' key
287 288 289 |
# File 'lib/api_hammer/halt_methods.rb', line 287 def halt_request_header_fields_too_large(errors, = {}) halt_error(431, errors, ) end |
#halt_request_timeout(errors, render_options = {}) ⇒ Object
halt with status 408 Request Timeout, responding with the given errors object on the 'errors' key
192 193 194 |
# File 'lib/api_hammer/halt_methods.rb', line 192 def halt_request_timeout(errors, = {}) halt_error(408, errors, ) end |
#halt_request_uri_too_long(errors, render_options = {}) ⇒ Object
halt with status 414 Request-URI Too Long, responding with the given errors object on the 'errors' key
222 223 224 |
# File 'lib/api_hammer/halt_methods.rb', line 222 def halt_request_uri_too_long(errors, = {}) halt_error(414, errors, ) end |
#halt_requested_range_not_satisfiable(errors, render_options = {}) ⇒ Object
halt with status 416 Requested Range Not Satisfiable, responding with the given errors object on the 'errors' key
232 233 234 |
# File 'lib/api_hammer/halt_methods.rb', line 232 def halt_requested_range_not_satisfiable(errors, = {}) halt_error(416, errors, ) end |
#halt_reset_content(render_options = {}) ⇒ Object
halt with status 205 Reset Content
87 88 89 |
# File 'lib/api_hammer/halt_methods.rb', line 87 def halt_reset_content( = {}) halt(205, '', ) end |
#halt_see_other(body, render_options = {}) ⇒ Object
halt with status 303 See Other, responding with the given body object
127 128 129 |
# File 'lib/api_hammer/halt_methods.rb', line 127 def halt_see_other(body, = {}) halt(303, body, ) end |
#halt_service_unavailable(errors, render_options = {}) ⇒ Object
halt with status 503 Service Unavailable, responding with the given errors object on the 'errors' key
322 323 324 |
# File 'lib/api_hammer/halt_methods.rb', line 322 def halt_service_unavailable(errors, = {}) halt_error(503, errors, ) end |
#halt_temporary_redirect(body, render_options = {}) ⇒ Object
halt with status 307 Temporary Redirect, responding with the given body object
142 143 144 |
# File 'lib/api_hammer/halt_methods.rb', line 142 def halt_temporary_redirect(body, = {}) halt(307, body, ) end |
#halt_too_many_requests(errors, render_options = {}) ⇒ Object
halt with status 429 Too Many Requests, responding with the given errors object on the 'errors' key
282 283 284 |
# File 'lib/api_hammer/halt_methods.rb', line 282 def halt_too_many_requests(errors, = {}) halt_error(429, errors, ) end |
#halt_unauthorized(errors, render_options = {}) ⇒ Object
halt with status 401 Unauthorized, responding with the given errors object on the 'errors' key
157 158 159 |
# File 'lib/api_hammer/halt_methods.rb', line 157 def (errors, = {}) halt_error(401, errors, ) end |
#halt_unavailable_for_legal_reasons(errors, render_options = {}) ⇒ Object
halt with status 451 Unavailable For Legal Reasons, responding with the given errors object on the 'errors' key
297 298 299 |
# File 'lib/api_hammer/halt_methods.rb', line 297 def halt_unavailable_for_legal_reasons(errors, = {}) halt_error(451, errors, ) end |
#halt_unordered_collection(errors, render_options = {}) ⇒ Object
halt with status 425 Unordered Collection, responding with the given errors object on the 'errors' key
267 268 269 |
# File 'lib/api_hammer/halt_methods.rb', line 267 def halt_unordered_collection(errors, = {}) halt_error(425, errors, ) end |
#halt_unprocessable_entity(errors, render_options = {}) ⇒ Object
halt with status 422 Unprocessable Entity, responding with the given errors object on the 'errors' key
252 253 254 |
# File 'lib/api_hammer/halt_methods.rb', line 252 def halt_unprocessable_entity(errors, = {}) halt_error(422, errors, ) end |
#halt_unsupported_media_type(errors, render_options = {}) ⇒ Object
halt with status 415 Unsupported Media Type, responding with the given errors object on the 'errors' key
227 228 229 |
# File 'lib/api_hammer/halt_methods.rb', line 227 def halt_unsupported_media_type(errors, = {}) halt_error(415, errors, ) end |
#halt_upgrade_required(errors, render_options = {}) ⇒ Object
halt with status 426 Upgrade Required, responding with the given errors object on the 'errors' key
272 273 274 |
# File 'lib/api_hammer/halt_methods.rb', line 272 def halt_upgrade_required(errors, = {}) halt_error(426, errors, ) end |
#halt_use_proxy(body, render_options = {}) ⇒ Object
halt with status 305 Use Proxy, responding with the given body object
137 138 139 |
# File 'lib/api_hammer/halt_methods.rb', line 137 def halt_use_proxy(body, = {}) halt(305, body, ) end |
#halt_variant_also_negotiates(errors, render_options = {}) ⇒ Object
halt with status 506 Variant Also Negotiates, responding with the given errors object on the 'errors' key
337 338 339 |
# File 'lib/api_hammer/halt_methods.rb', line 337 def halt_variant_also_negotiates(errors, = {}) halt_error(506, errors, ) end |