syntax = "proto3"; package demo; import "google/api/annotations.proto"; option go_package = "hilo/api/demo;demo"; // 定义服务 service Demo { rpc Hello (HelloReq) returns (HelloRep) { option (google.api.http) = { get: "/demo/hello/{name}" }; } rpc Create (CreateReq) returns (OKRep) { option (google.api.http) = { post: "/demo/create", body: "*" }; } rpc Update (UpdateReq) returns (OKRep) { option (google.api.http) = { post: "/demo/update", body: "*" }; } rpc Get (IdReq) returns (DemoModel) { option (google.api.http) = { get: "/demo/get", }; } rpc List (ListReq) returns (ListRep) { option (google.api.http) = { get: "/demo/list", }; } rpc Delete (IdReq) returns (OKRep) { option (google.api.http) = { get: "/demo/delete", }; } } message DemoModel { int64 id = 1; string name = 2; string value = 3; int64 created_at = 4; int64 updated_at = 5; } message IdReq { int64 id = 1; // @gotags: validate:"required,min=1" } message ListReq { int64 page = 1; // @gotags: validate:"min=0" int64 size = 2; // @gotags: validate:"min=0" } message ListRep { repeated DemoModel list = 1; } message CreateReq { string name = 1; // @gotags: validate:"required" string value = 2; // @gotags: validate:"required" } message UpdateReq { int64 id = 1; // @gotags: validate:"required" string name = 2; // @gotags: validate:"required" string value = 3; // @gotags: validate:"required" } message OKRep {} message HelloReq { string name = 1; } message HelloRep { string message = 1; }