Sha256: 8579cfddb0f6b1c0c07418d4c65f2d964a58a9270cd2726d8ac549ccc38e785e
Contents?: true
Size: 1.86 KB
Versions: 5
Compression:
Stored size: 1.86 KB
Contents
# typed: false # frozen_string_literal: true class ApplicationController < ActionController::Base include ActionController::MimeResponds rescue_from ActionController::UnknownFormat, with: :not_acceptable before_action :set_request_span_context def set_request_span_context end after_action :set_response_span_context def set_response_span_context OpenTelemetry::Trace.current_span.add_attributes({ OpenTelemetry::SemanticConventions::Trace::HTTP_RESPONSE_CONTENT_LENGTH => response.headers["content-length"] || 0, }) end def no_content head(:no_content) end def okay render( json: { message: "OK", }.to_json, status: :ok, ) end def created render( json: { message: "Created", }.to_json, status: :created, ) end def bad_request render( json: { errors: [ { message: "Bad Request", }, ], }.to_json, status: :bad_request, ) end def forbidden render( json: { errors: [ { message: "Forbidden", }, ], }.to_json, status: :forbidden, ) end def not_acceptable(e) render( json: ::ErrorSerializer.format("Not Acceptable").to_json, status: :not_acceptable, ) end def not_found render( json: ::ErrorSerializer.format("Not Found").to_json, status: :not_found, ) end def service_unavailable(msg) render( json: { errors: [ { message: "Service Unavailable: #{msg}", }, ], }.to_json, status: :service_unavailable, ) end def bad_gateway render( json: { errors: [ { message: "Bad Gateway", }, ], }.to_json, status: :bad_gateway, ) end end
Version data entries
5 entries across 5 versions & 1 rubygems