Sha256: 8ecc4a5f30a6dfbe237ad90b31fe5546657e2f2e3a69dba209cc39504cf25be7

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

class PingsController < ApplicationTwirpController
  before_action :respond_error, only: :before_error

  def ping
    response = RPC::DummyAPI::PingResponse.new(double_name: request.name * 2)
    self.response_body = response
  end

  def ping_render
    response = RPC::DummyAPI::PingResponse.new(double_name: request.name * 2)
    render pb: response
  end

  def ping_template
    @double_name = request.name * 2
  end

  def error_response
    error :unauthenticated, "You are not authenticated!!"
  end

  def raise_error
    # This error is rescued in ApplicationTwirpController
    raise ActiveRecord::RecordNotFound, "Not found"
  end

  def uncaught_raise
    raise StandardError, "Uncaught"
  end

  def before_error
    # This error won't be reached because of the before_action
    raise NotImplementedError
  end

  def respond_error
    error :malformed, "yOuR ReQuEsT Is mAlFoRmEd"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_twirp-0.3.0 test/dummy/app/controllers/pings_controller.rb