Skip to content

Instantly share code, notes, and snippets.

@oppai
Last active May 31, 2019 17:03
Show Gist options
  • Save oppai/9f3cdf32090b89029406e30ccdd4ea04 to your computer and use it in GitHub Desktop.
Save oppai/9f3cdf32090b89029406e30ccdd4ea04 to your computer and use it in GitHub Desktop.
enum StatusCode {
  success = 0;
  failure = 1;
  unknown = 2;
}
# tony612/protobuf-elixir
iex(3)> StatusCode.value(:success)
0
iex(4)> StatusCode.value(:failure)
1

# xflagstudio/protobuf-elixir
iex(5)> StatusCode.success()
0
iex(6)> StatusCode.failure()
1
environment :dev do
set(include_erts: true)
set(include_src: false)
set(cookie: :"xxxxxxxxxxxxxxxxxxxxxx")
end
release :api do
set(version: current_version(:api))
set(config: "apps/api/config/config.exs")
set(applications: [:api])
end
release :admin_tool do
set(version: current_version(:admin_tool))
set(config: "apps/admin_tool/config/config.exs")
set(applications: [:admin_tool])
end
release :api_all do
set(version: current_version(:allinone))
set(applications: [:api, :admin_tool])
end
defmodule Api.Sample.Request do
@moduledoc false
use Protobuf, syntax: :proto3
defstruct []
end
defmodule Api.Sample.Response do
@moduledoc false
use Protobuf, syntax: :proto3
@type t :: %__MODULE__{
status: non_neg_integer,
message: String.t()
}
defstruct [:status, :message]
field :status, 1, type: :uint32
field :message, 2, type: :string
end
/**
* PINGを飛ばせるサンプルAPI
*
* | *Path* | *Method* |
* | ------ | -------- |
* | /sample/ping | GET
*/
syntax = "proto3";
package api.sample;
import "google/api/annotations.proto";
service Service {
rpc SamplePing(Request) returns (Response) {
option (google.api.http) = {
get: "/sample/ping"
};
}
}
/**
* リクエストパラメータ
*/
message Request {}
/**
* レスポンス
*/
message Response {
uint32 status = 1; // ステータスコード
string message = 2; // レスポンスメッセージ
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment