initial commit
This commit is contained in:
127
proto/service.proto
Normal file
127
proto/service.proto
Normal file
@ -0,0 +1,127 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package peach;
|
||||
|
||||
import "gorm/options/gorm.proto";
|
||||
//import "gorm/types/types.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||
|
||||
option go_package = "./;pb";
|
||||
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "Your API Title"
|
||||
version: "v1.0"
|
||||
description: "Your API description"
|
||||
}
|
||||
host: "localhost:8080" // Set the server host
|
||||
};
|
||||
|
||||
service Peach {
|
||||
option (gorm.server).autogen = true;
|
||||
// Add your service methods here
|
||||
|
||||
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/users"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ReadUser (ReadUserRequest) returns (ReadUserResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/users/{id}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListUsers (ListUsersRequest) returns (ListUsersResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/users"
|
||||
};
|
||||
}
|
||||
|
||||
rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse) {
|
||||
option (google.api.http) = {
|
||||
put: "/v1/users"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse) {
|
||||
option (gorm.method).object_type = "User";
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/users/{id}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc CreateProduct (CreateProductRequest) returns (CreateProductResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/Product"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ReadProduct (ReadProductRequest) returns (ReadProductResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/Product/{id}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListProducts (ListProductsRequest) returns (ListProductsResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/Product"
|
||||
};
|
||||
}
|
||||
|
||||
rpc UpdateProduct (UpdateProductRequest) returns (UpdateProductResponse) {
|
||||
option (google.api.http) = {
|
||||
put: "/v1/Product"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc DeleteProduct (DeleteProductRequest) returns (DeleteProductResponse) {
|
||||
option (gorm.method).object_type = "Product";
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/Product/{id}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message CreateUserRequest { User payload=1; }
|
||||
message CreateUserResponse { User result=1; }
|
||||
message ReadUserRequest { uint64 id=1; }
|
||||
message ReadUserResponse { User result=1; }
|
||||
message ListUsersRequest {}
|
||||
message ListUsersResponse { repeated User results=1; }
|
||||
message UpdateUserRequest { User payload=1; }
|
||||
message UpdateUserResponse { User result=1; }
|
||||
message DeleteUserRequest { uint64 id=1; }
|
||||
message DeleteUserResponse {}
|
||||
|
||||
message User {
|
||||
option (gorm.opts).ormable = true;
|
||||
uint64 id = 1;
|
||||
string username = 2;
|
||||
string bio = 3;
|
||||
}
|
||||
|
||||
message CreateProductRequest { Product payload=1; }
|
||||
message CreateProductResponse { Product result=1; }
|
||||
message ReadProductRequest { uint64 id=1; }
|
||||
message ReadProductResponse { Product result=1; }
|
||||
message ListProductsRequest {}
|
||||
message ListProductsResponse { repeated Product results=1; }
|
||||
message UpdateProductRequest { Product payload=1; }
|
||||
message UpdateProductResponse { Product result=1; }
|
||||
message DeleteProductRequest { uint64 id=1; }
|
||||
message DeleteProductResponse {}
|
||||
|
||||
message Product {
|
||||
option (gorm.opts).ormable = true;
|
||||
uint64 id = 1;
|
||||
string name = 2;
|
||||
string description = 3;
|
||||
float price = 4;
|
||||
}
|
Reference in New Issue
Block a user