-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from collectiveidea/handler-packages
Look for handlers in both the fully-qualified namespace, or root namespace.
- Loading branch information
Showing
10 changed files
with
131 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ ruby_version: 2.7 | |
plugins: | ||
- standard-performance | ||
- standard-rails | ||
ignore: | ||
- '**/*_pb.rb' | ||
- '**/*_twirp.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spec/rails_app/app/handlers/twirp/example/cobbler/cobbler_handler.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Twirp | ||
module Example | ||
module Cobbler | ||
class CobblerHandler < Twirp::Rails::Handler | ||
def make_shoe | ||
# We can return a Twirp::Error when appropriate | ||
if request.inches < 12 | ||
return Twirp::Error.invalid_argument("is too small", argument: "inches") | ||
end | ||
|
||
# Build the reponse | ||
Twirp::Example::Cobbler::Shoe.new( | ||
inches: request.inches, | ||
name: "Pork Pie", | ||
color: "Tan" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
# Generated by the protoc-gen-twirp_ruby gem v1.1.1. DO NOT EDIT! | ||
# source: twirp/example/cobbler/cobbler.proto | ||
|
||
require "twirp" | ||
require_relative "cobbler_pb" | ||
|
||
module Twirp | ||
module Example | ||
module Cobbler | ||
class CobblerService < ::Twirp::Service | ||
package "twirp.example.cobbler" | ||
service "Cobbler" | ||
rpc :MakeShoe, Size, Shoe, ruby_method: :make_shoe | ||
end | ||
|
||
class CobblerClient < ::Twirp::Client | ||
client_for CobblerService | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// A close copy of haberdasher.proto | ||
// We're putting this in /proto/twirp/example/cobbler/ so that we can test namespace handling | ||
syntax = "proto3"; | ||
|
||
package twirp.example.cobbler; | ||
|
||
// Cobbler service makes shoes for clients. | ||
service Cobbler { | ||
// MakeShoe produces a shoe of mysterious, randomly-selected color! | ||
rpc MakeShoe(Size) returns (Shoe); | ||
} | ||
|
||
// Size of a Shoe, in inches. | ||
message Size { | ||
int32 inches = 1; // must be > 0 | ||
} | ||
|
||
// A Shoe is a piece of footwear made by a Cobbler. | ||
message Shoe { | ||
int32 inches = 1; | ||
string color = 2; // anything but "invisible" | ||
string name = 3; // i.e. "oxford" | ||
} |