├── deploy ├── docker │ └── Dockerfile ├── k8s │ └── deployments.yaml └── docker-compose │ └── docker-compose.yaml ├── .gitignore ├── third_party ├── README.md ├── validate │ ├── README.md │ └── validate.proto ├── errors │ └── errors.proto ├── google │ └── api │ │ ├── annotations.proto │ │ ├── httpbody.proto │ │ ├── field_behavior.proto │ │ ├── client.proto │ │ └── http.proto └── protoc-gen-openapiv2 │ └── options │ ├── annotations.proto │ └── openapiv2.proto ├── internal ├── server │ ├── server.go │ ├── grpc.go │ └── http.go ├── biz │ ├── order.go │ ├── user.go │ ├── biz.go │ └── biz_user.go ├── service │ ├── service.go │ └── user.go ├── data │ ├── model │ │ └── user.go │ ├── data.go │ └── user.go └── conf │ ├── conf.proto │ └── conf.pb.go ├── README.md ├── configs └── config.yaml ├── api └── v1 │ ├── errors.proto │ ├── errors.swagger.json │ ├── errors_errors.pb.go │ ├── api.proto │ ├── errors.pb.go │ ├── api.swagger.json │ ├── api_http.pb.go │ ├── api_grpc.pb.go │ └── api.pb.go ├── Dockerfile ├── cmd └── go-web-layout │ ├── wire.go │ ├── main.go │ └── wire_gen.go ├── go.mod ├── Makefile └── go.sum /deploy/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deploy/k8s/deployments.yaml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | bin -------------------------------------------------------------------------------- /deploy/docker-compose/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/README.md: -------------------------------------------------------------------------------- 1 | # third_party 2 | -------------------------------------------------------------------------------- /third_party/validate/README.md: -------------------------------------------------------------------------------- 1 | # protoc-gen-validate (PGV) 2 | 3 | * https://github.com/envoyproxy/protoc-gen-validate 4 | -------------------------------------------------------------------------------- /internal/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/google/wire" 5 | ) 6 | 7 | var ProviderSet = wire.NewSet(NewGRPCServer, NewHTTPServer) 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 工程目录example 2 | 3 | ## 开发环境 4 | - go version: go1.20 5 | - IDE: goland 6 | 7 | ## 镜像构建 8 | ```bash 9 | docker build --target api -f Dockerfile -t go-web-layout . 10 | ``` -------------------------------------------------------------------------------- /internal/biz/order.go: -------------------------------------------------------------------------------- 1 | package biz 2 | 3 | import "time" 4 | 5 | type Order struct { 6 | // 订单ID 7 | Id uint 8 | // 订单名称 9 | OrderName string 10 | // 订单时间 11 | OrderCratedTime time.Time 12 | } 13 | -------------------------------------------------------------------------------- /internal/service/service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import "github.com/google/wire" 4 | 5 | var ProviderSet = wire.NewSet(NewUserService, wire.Struct(new(Set), "*")) 6 | 7 | type Set struct { 8 | User *UserService 9 | } 10 | -------------------------------------------------------------------------------- /configs/config.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | http: 3 | network: tcp 4 | addr: :8080 5 | timeout: 10s 6 | grpc: 7 | network: tcp 8 | addr: :8081 9 | timeout: 10s 10 | data: 11 | database: 12 | driver: mysql 13 | source: root:admin123@tcp(localhost:3306)/web_layout?charset=utf8mb4&parseTime=True&loc=Local -------------------------------------------------------------------------------- /internal/biz/user.go: -------------------------------------------------------------------------------- 1 | package biz 2 | 3 | type ( 4 | // User 用户信息 5 | User struct { 6 | Uid int64 7 | Password string 8 | Username string 9 | Email string 10 | } 11 | // Users 用户列表 12 | Users []*User 13 | // UserPage 用户分页 14 | UserPage struct { 15 | Total int64 16 | Items Users 17 | } 18 | ) 19 | -------------------------------------------------------------------------------- /api/v1/errors.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package api; 4 | import "errors/errors.proto"; 5 | 6 | option go_package = "github.com/lyouthzzz/go-web-layout/api/v1;apiV1"; 7 | 8 | enum ErrorReason { 9 | option (errors.default_code) = 500; 10 | option (errors.default_message) = "未知错误"; 11 | 12 | UNKNOWN = 0; 13 | NOT_FOUNT = 1 [(errors.code) = 404]; 14 | } -------------------------------------------------------------------------------- /internal/data/model/user.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type User struct { 4 | ID uint64 `gorm:"column:id;PRIMARY_KEY;AUTO_INCREMENT"` 5 | Username string `gorm:"column:username;type:char(60);NOT NULL"` 6 | Password string `gorm:"column:password;type:char(60);NOT NULL"` 7 | Email string `gorm:"column:email;type:char(60);NOT NULL"` 8 | } 9 | 10 | func (User) TableName() string { 11 | return "user" 12 | } 13 | -------------------------------------------------------------------------------- /third_party/errors/errors.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package errors; 4 | 5 | option go_package = "github.com/go-kratos/kratos/v2/errors;errors"; 6 | option java_multiple_files = true; 7 | option java_package = "com.github.kratos.errors"; 8 | option objc_class_prefix = "KratosErrors"; 9 | 10 | import "google/protobuf/descriptor.proto"; 11 | 12 | extend google.protobuf.EnumOptions { 13 | int32 default_code = 1108; 14 | string default_message = 1109; 15 | } 16 | 17 | extend google.protobuf.EnumValueOptions { 18 | int32 code = 1110; 19 | string message = 1111; 20 | } -------------------------------------------------------------------------------- /internal/biz/biz.go: -------------------------------------------------------------------------------- 1 | package biz 2 | 3 | import ( 4 | "context" 5 | "github.com/google/wire" 6 | ) 7 | 8 | /** 9 | biz.go文件有如下作用: 10 | 1. 定义Repo层接口 11 | 2. 定义三方防腐层接口 12 | 3. 维护biz层wire provider set 13 | */ 14 | 15 | var ProviderSet = wire.NewSet(NewUserUsecase) 16 | 17 | // UserRepo 用户接口 18 | type UserRepo interface { 19 | GetUser(ctx context.Context, id int64) (*User, error) 20 | CreateUser(ctx context.Context, user *User) error 21 | UpdateUser(ctx context.Context, user *User) error 22 | DeleteUser(ctx context.Context, id int64) error 23 | ListUser(ctx context.Context, offset, limit int64) (*UserPage, error) 24 | } 25 | -------------------------------------------------------------------------------- /internal/server/grpc.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/go-kratos/kratos/v2/transport/grpc" 5 | apiV1 "github.com/lyouthzzz/go-web-layout/api/v1" 6 | "github.com/lyouthzzz/go-web-layout/internal/conf" 7 | "github.com/lyouthzzz/go-web-layout/internal/service" 8 | ) 9 | 10 | func NewGRPCServer(config *conf.Server, serviceSet *service.Set) (*grpc.Server, error) { 11 | grpcServer := grpc.NewServer(grpc.Network(config.Grpc.Network), grpc.Address(config.Grpc.Addr), grpc.Timeout(config.Grpc.Timeout.AsDuration())) 12 | 13 | apiV1.RegisterUserServiceServer(grpcServer, serviceSet.User) 14 | 15 | return grpcServer, nil 16 | } 17 | -------------------------------------------------------------------------------- /internal/server/http.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/go-kratos/kratos/v2/transport/http" 5 | apiV1 "github.com/lyouthzzz/go-web-layout/api/v1" 6 | "github.com/lyouthzzz/go-web-layout/internal/conf" 7 | "github.com/lyouthzzz/go-web-layout/internal/service" 8 | ) 9 | 10 | func NewHTTPServer(config *conf.Server, serviceSet *service.Set) (*http.Server, error) { 11 | httpServer := http.NewServer(http.Network(config.Http.Network), http.Address(config.Http.Addr), http.Timeout(config.Http.Timeout.AsDuration())) 12 | 13 | apiV1.RegisterUserServiceHTTPServer(httpServer, serviceSet.User) 14 | 15 | return httpServer, nil 16 | } 17 | -------------------------------------------------------------------------------- /internal/data/data.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "github.com/google/wire" 5 | "github.com/lyouthzzz/go-web-layout/internal/conf" 6 | "github.com/lyouthzzz/go-web-layout/internal/data/model" 7 | "gorm.io/driver/mysql" 8 | "gorm.io/gorm" 9 | ) 10 | 11 | var ProviderSet = wire.NewSet(NewData, NewUserRepo) 12 | 13 | type Data struct { 14 | db *gorm.DB 15 | } 16 | 17 | func NewData(conf *conf.Data) (*Data, func(), error) { 18 | db, err := gorm.Open(mysql.Open(conf.Database.Source)) 19 | if err != nil { 20 | panic(err) 21 | } 22 | if err = db.AutoMigrate(&model.User{}); err != nil { 23 | panic(err) 24 | } 25 | return &Data{db: db}, func() {}, nil 26 | } 27 | -------------------------------------------------------------------------------- /internal/biz/biz_user.go: -------------------------------------------------------------------------------- 1 | package biz 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type Usecase struct { 8 | user UserRepo 9 | } 10 | 11 | func NewUserUsecase(user UserRepo) *Usecase { 12 | return &Usecase{user: user} 13 | } 14 | 15 | func (uc *Usecase) GetUser(ctx context.Context, uid int64) (*User, error) { 16 | return uc.user.GetUser(ctx, uid) 17 | } 18 | 19 | func (uc *Usecase) CreateUser(ctx context.Context, user *User) error { 20 | return uc.user.CreateUser(ctx, user) 21 | } 22 | 23 | func (uc *Usecase) UpdateUser(ctx context.Context, user *User) error { 24 | return uc.user.UpdateUser(ctx, user) 25 | } 26 | 27 | func (uc *Usecase) DeleteUser(ctx context.Context, uid int64) error { 28 | return uc.user.DeleteUser(ctx, uid) 29 | } 30 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-alpine3.18 AS builder 2 | 3 | WORKDIR /root 4 | 5 | COPY . . 6 | 7 | RUN --mount=type=cache,target=/go/pkg/mod \ 8 | --mount=type=cache,target=/root/.cache/go-build \ 9 | mkdir -p bin/ && GOPROXY="https://goproxy.cn,direct" go build -ldflags '-w -s -extldflags "-static"' -o ./bin/ ./... 10 | 11 | FROM alpine:3.18 as api 12 | 13 | RUN apk update && apk add --no-cache ca-certificates && \ 14 | apk add tzdata && \ 15 | ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ 16 | echo "Asia/Shanghai" > /etc/timezone 17 | 18 | COPY --from=builder /root/bin /app 19 | 20 | WORKDIR /app 21 | 22 | EXPOSE 8080 23 | EXPOSE 8081 24 | 25 | ADD ./configs /app/configs 26 | 27 | CMD ["./go-web-layout", "--config", "/app/configs/config.yaml"] -------------------------------------------------------------------------------- /internal/conf/conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package weblayout.config; 4 | 5 | option go_package = "github.com/lyouthzzz/go-web-layout/internal/conf;conf"; 6 | 7 | import "google/protobuf/duration.proto"; 8 | 9 | message Bootstrap { 10 | Server server = 2; 11 | Data data = 3; 12 | } 13 | 14 | message Server { 15 | message HTTP { 16 | string network = 1; 17 | string addr = 2; 18 | google.protobuf.Duration timeout = 3; 19 | } 20 | message GRPC { 21 | string network = 1; 22 | string addr = 2; 23 | google.protobuf.Duration timeout = 3; 24 | } 25 | HTTP http = 1; 26 | GRPC grpc = 2; 27 | } 28 | 29 | message Data { 30 | message Database { 31 | string driver = 1; 32 | string source = 2; 33 | } 34 | Database database = 1; 35 | } -------------------------------------------------------------------------------- /cmd/go-web-layout/wire.go: -------------------------------------------------------------------------------- 1 | //go:build wireinject 2 | // +build wireinject 3 | 4 | // 5 | //The build tag makes sure the stub is not built in the final build. 6 | 7 | package main 8 | 9 | import ( 10 | "github.com/go-kratos/kratos/v2" 11 | "github.com/go-kratos/kratos/v2/log" 12 | "github.com/google/wire" 13 | "github.com/lyouthzzz/go-web-layout/internal/biz" 14 | "github.com/lyouthzzz/go-web-layout/internal/conf" 15 | "github.com/lyouthzzz/go-web-layout/internal/data" 16 | "github.com/lyouthzzz/go-web-layout/internal/server" 17 | "github.com/lyouthzzz/go-web-layout/internal/service" 18 | ) 19 | 20 | func initApp(*conf.Server, *conf.Data, log.Logger) (*kratos.App, func(), error) { 21 | panic(wire.Build(data.ProviderSet, biz.ProviderSet, service.ProviderSet, server.ProviderSet, newApp)) 22 | } 23 | -------------------------------------------------------------------------------- /api/v1/errors.swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "title": "api/v1/errors.proto", 5 | "version": "version not set" 6 | }, 7 | "consumes": [ 8 | "application/json" 9 | ], 10 | "produces": [ 11 | "application/json" 12 | ], 13 | "paths": {}, 14 | "definitions": { 15 | "protobufAny": { 16 | "type": "object", 17 | "properties": { 18 | "@type": { 19 | "type": "string" 20 | } 21 | }, 22 | "additionalProperties": {} 23 | }, 24 | "rpcStatus": { 25 | "type": "object", 26 | "properties": { 27 | "code": { 28 | "type": "integer", 29 | "format": "int32" 30 | }, 31 | "message": { 32 | "type": "string" 33 | }, 34 | "details": { 35 | "type": "array", 36 | "items": { 37 | "$ref": "#/definitions/protobufAny" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /internal/data/user.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "context" 5 | "github.com/lyouthzzz/go-web-layout/internal/biz" 6 | ) 7 | 8 | var _ biz.UserRepo = (*userRepo)(nil) 9 | 10 | type userRepo struct { 11 | data *Data 12 | } 13 | 14 | func NewUserRepo(data *Data) biz.UserRepo { 15 | return &userRepo{data: data} 16 | } 17 | 18 | func (repo *userRepo) GetUser(ctx context.Context, id int64) (*biz.User, error) { 19 | panic("GetUser implement me") 20 | } 21 | 22 | func (repo *userRepo) CreateUser(ctx context.Context, user *biz.User) error { 23 | panic("CreateUser implement me") 24 | } 25 | 26 | func (repo *userRepo) UpdateUser(ctx context.Context, user *biz.User) error { 27 | panic("UpdateUser implement me") 28 | } 29 | 30 | func (repo *userRepo) DeleteUser(ctx context.Context, uid int64) error { 31 | panic("DeleteUser implement me") 32 | } 33 | 34 | func (repo *userRepo) ListUser(ctx context.Context, offset, limit int64) (*biz.UserPage, error) { 35 | panic("ListUser implement me") 36 | } 37 | -------------------------------------------------------------------------------- /third_party/google/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/http.proto"; 20 | import "google/protobuf/descriptor.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "AnnotationsProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | extend google.protobuf.MethodOptions { 29 | // See `HttpRule`. 30 | HttpRule http = 72295728; 31 | } 32 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lyouthzzz/go-web-layout 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/go-kratos/kratos/v2 v2.7.2 7 | github.com/google/wire v0.5.0 8 | google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 9 | google.golang.org/grpc v1.56.3 10 | google.golang.org/protobuf v1.31.0 11 | gorm.io/driver/mysql v1.3.3 12 | gorm.io/gorm v1.23.5 13 | ) 14 | 15 | require ( 16 | github.com/fsnotify/fsnotify v1.6.0 // indirect 17 | github.com/go-kratos/aegis v0.2.0 // indirect 18 | github.com/go-playground/form/v4 v4.2.0 // indirect 19 | github.com/go-sql-driver/mysql v1.6.0 // indirect 20 | github.com/golang/protobuf v1.5.3 // indirect 21 | github.com/google/uuid v1.3.0 // indirect 22 | github.com/gorilla/mux v1.8.0 // indirect 23 | github.com/imdario/mergo v0.3.16 // indirect 24 | github.com/jinzhu/inflection v1.0.0 // indirect 25 | github.com/jinzhu/now v1.1.4 // indirect 26 | github.com/kr/text v0.2.0 // indirect 27 | golang.org/x/net v0.17.0 // indirect 28 | golang.org/x/sync v0.3.0 // indirect 29 | golang.org/x/sys v0.13.0 // indirect 30 | golang.org/x/text v0.13.0 // indirect 31 | google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 // indirect 32 | google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529 // indirect 33 | gopkg.in/yaml.v3 v3.0.1 // indirect 34 | ) 35 | -------------------------------------------------------------------------------- /api/v1/errors_errors.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-errors. DO NOT EDIT. 2 | 3 | package apiV1 4 | 5 | import ( 6 | fmt "fmt" 7 | errors "github.com/go-kratos/kratos/v2/errors" 8 | ) 9 | 10 | // This is a compile-time assertion to ensure that this generated file 11 | // is compatible with the kratos package it is being compiled against. 12 | const _ = errors.SupportPackageIsVersion1 13 | 14 | func IsUnknown(err error) bool { 15 | if err == nil { 16 | return false 17 | } 18 | e := errors.FromError(err) 19 | return e.Reason == ErrorReason_UNKNOWN.String() && e.Code == 500 20 | } 21 | 22 | func ErrorUnknown(format string, args ...interface{}) *errors.Error { 23 | return errors.New(500, ErrorReason_UNKNOWN.String(), fmt.Sprintf(format, args...)) 24 | } 25 | 26 | func ErrorMessageUnknown() *errors.Error { 27 | return errors.New(500, ErrorReason_UNKNOWN.String(), "未知错误") 28 | } 29 | 30 | func IsNotFount(err error) bool { 31 | if err == nil { 32 | return false 33 | } 34 | e := errors.FromError(err) 35 | return e.Reason == ErrorReason_NOT_FOUNT.String() && e.Code == 404 36 | } 37 | 38 | func ErrorNotFount(format string, args ...interface{}) *errors.Error { 39 | return errors.New(404, ErrorReason_NOT_FOUNT.String(), fmt.Sprintf(format, args...)) 40 | } 41 | 42 | func ErrorMessageNotFount() *errors.Error { 43 | return errors.New(404, ErrorReason_NOT_FOUNT.String(), "未知错误") 44 | } 45 | -------------------------------------------------------------------------------- /cmd/go-web-layout/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "github.com/go-kratos/kratos/v2" 6 | "github.com/go-kratos/kratos/v2/config" 7 | "github.com/go-kratos/kratos/v2/config/file" 8 | "github.com/go-kratos/kratos/v2/log" 9 | "github.com/go-kratos/kratos/v2/transport/grpc" 10 | "github.com/go-kratos/kratos/v2/transport/http" 11 | "github.com/lyouthzzz/go-web-layout/internal/conf" 12 | "os" 13 | ) 14 | 15 | var flagConfig string 16 | 17 | func init() { 18 | flag.StringVar(&flagConfig, "config", "configs/config.yaml", "config path, eg: --config config.yaml") 19 | } 20 | 21 | func newApp(logger log.Logger, grpcServer *grpc.Server, httpServer *http.Server) *kratos.App { 22 | return kratos.New( 23 | kratos.Name("go-web-layout"), 24 | kratos.Version("0.0.1"), 25 | kratos.Logger(logger), 26 | kratos.Server(grpcServer, httpServer), 27 | ) 28 | } 29 | 30 | func main() { 31 | flag.Parse() 32 | 33 | logger := log.With(log.NewStdLogger(os.Stdout)) 34 | 35 | c := config.New( 36 | config.WithSource( 37 | file.NewSource(flagConfig), 38 | ), 39 | ) 40 | if err := c.Load(); err != nil { 41 | panic(err) 42 | } 43 | var bc conf.Bootstrap 44 | if err := c.Scan(&bc); err != nil { 45 | panic(err) 46 | } 47 | app, cleanup, err := initApp(bc.Server, bc.Data, logger) 48 | if err != nil { 49 | panic(err) 50 | } 51 | defer cleanup() 52 | if err := app.Run(); err != nil { 53 | panic(err) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /cmd/go-web-layout/wire_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by Wire. DO NOT EDIT. 2 | 3 | //go:generate go run github.com/google/wire/cmd/wire 4 | //go:build !wireinject 5 | // +build !wireinject 6 | 7 | package main 8 | 9 | import ( 10 | "github.com/go-kratos/kratos/v2" 11 | "github.com/go-kratos/kratos/v2/log" 12 | "github.com/lyouthzzz/go-web-layout/internal/biz" 13 | "github.com/lyouthzzz/go-web-layout/internal/conf" 14 | "github.com/lyouthzzz/go-web-layout/internal/data" 15 | "github.com/lyouthzzz/go-web-layout/internal/server" 16 | "github.com/lyouthzzz/go-web-layout/internal/service" 17 | ) 18 | 19 | // Injectors from wire.go: 20 | 21 | func initApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (*kratos.App, func(), error) { 22 | dataData, cleanup, err := data.NewData(confData) 23 | if err != nil { 24 | return nil, nil, err 25 | } 26 | userRepo := data.NewUserRepo(dataData) 27 | usecase := biz.NewUserUsecase(userRepo) 28 | userService := service.NewUserService(usecase) 29 | set := &service.Set{ 30 | User: userService, 31 | } 32 | grpcServer, err := server.NewGRPCServer(confServer, set) 33 | if err != nil { 34 | cleanup() 35 | return nil, nil, err 36 | } 37 | httpServer, err := server.NewHTTPServer(confServer, set) 38 | if err != nil { 39 | cleanup() 40 | return nil, nil, err 41 | } 42 | app := newApp(logger, grpcServer, httpServer) 43 | return app, func() { 44 | cleanup() 45 | }, nil 46 | } 47 | -------------------------------------------------------------------------------- /internal/service/user.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "context" 5 | apiV1 "github.com/lyouthzzz/go-web-layout/api/v1" 6 | "github.com/lyouthzzz/go-web-layout/internal/biz" 7 | ) 8 | 9 | type UserService struct { 10 | apiV1.UnimplementedUserServiceServer 11 | user *biz.Usecase 12 | } 13 | 14 | func NewUserService(uc *biz.Usecase) *UserService { 15 | return &UserService{user: uc} 16 | } 17 | 18 | func (svc *UserService) GetUser(ctx context.Context, req *apiV1.GetUserRequest) (*apiV1.User, error) { 19 | user, err := svc.user.GetUser(ctx, req.Uid) 20 | if err != nil { 21 | return nil, err 22 | } 23 | return &apiV1.User{Uid: user.Uid, Username: user.Username, Email: user.Email}, nil 24 | } 25 | 26 | func (svc *UserService) CreateUser(ctx context.Context, req *apiV1.CreateUserRequest) (*apiV1.Empty, error) { 27 | if err := svc.user.CreateUser(ctx, &biz.User{ 28 | Username: req.Username, 29 | Password: req.Password, 30 | Email: req.Email, 31 | }); err != nil { 32 | return nil, err 33 | } 34 | return &apiV1.Empty{}, nil 35 | } 36 | 37 | func (svc *UserService) UpdateUser(ctx context.Context, req *apiV1.UpdateUserRequest) (*apiV1.Empty, error) { 38 | if err := svc.user.UpdateUser(ctx, &biz.User{ 39 | Password: req.Password, 40 | Email: req.Email, 41 | }); err != nil { 42 | return nil, err 43 | } 44 | return &apiV1.Empty{}, nil 45 | } 46 | 47 | func (svc *UserService) DeleteUser(ctx context.Context, req *apiV1.DeleteUserRequest) (*apiV1.Empty, error) { 48 | if err := svc.user.DeleteUser(ctx, req.Uid); err != nil { 49 | return nil, err 50 | } 51 | return &apiV1.Empty{}, nil 52 | } 53 | -------------------------------------------------------------------------------- /api/v1/api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package user.v1; 4 | 5 | option go_package = "github.com/lyouthzzz/go-web-layout/api/v1;apiV1"; 6 | 7 | import "google/api/annotations.proto"; 8 | 9 | // 用户API服务 10 | service UserService { 11 | // 获取用户 12 | rpc GetUser(GetUserRequest) returns (User) { 13 | option(google.api.http) = {get: "/users/{uid}"}; 14 | } 15 | // 创建用户 16 | rpc CreateUser(CreateUserRequest) returns (Empty) { 17 | option(google.api.http) = {post: "/users", body: "*"}; 18 | } 19 | // 更新用户 20 | rpc UpdateUser (UpdateUserRequest) returns (Empty) { 21 | option(google.api.http) = {put: "/users/{uid}", body: "*"}; 22 | } 23 | // 删除用户 24 | rpc DeleteUser (DeleteUserRequest) returns (Empty) { 25 | option(google.api.http) = {delete: "/users/{uid}"}; 26 | } 27 | // 获取用户列表 28 | rpc ListUser (ListUserRequest) returns (ListUserReply) { 29 | option(google.api.http) = {get: "/users"}; 30 | } 31 | } 32 | 33 | message Empty {} 34 | 35 | message User { 36 | int64 uid = 1; 37 | string username = 2; 38 | string password = 3; 39 | string email = 4; 40 | } 41 | 42 | message CreateUserRequest { 43 | // 用户名 44 | string username = 1; 45 | // 用户密码 46 | string password = 2; 47 | // 用户邮箱 48 | string email = 3; 49 | } 50 | 51 | message CreateUserReply { 52 | // 用户ID 53 | int64 uid = 1; 54 | } 55 | 56 | message UpdateUserRequest { 57 | // 用户ID 58 | int64 uid = 1; 59 | // 用户密码 60 | string password = 2; 61 | // 用户邮箱 62 | string email = 3; 63 | } 64 | 65 | message GetUserRequest { 66 | // 用户ID 67 | int64 uid = 1; 68 | } 69 | 70 | message DeleteUserRequest { 71 | // 用户ID 72 | int64 uid = 1; 73 | } 74 | 75 | message ListUserRequest { 76 | // 偏移量 77 | int64 offset = 1; 78 | // 每页数量 79 | int64 limit = 2; 80 | } 81 | 82 | message ListUserReply { 83 | // 总数 84 | int64 total = 1; 85 | // 用户列表 86 | repeated User items = 2; 87 | } -------------------------------------------------------------------------------- /third_party/protoc-gen-openapiv2/options/annotations.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package grpc.gateway.protoc_gen_openapiv2.options; 4 | 5 | option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; 6 | 7 | import "google/protobuf/descriptor.proto"; 8 | import "protoc-gen-openapiv2/options/openapiv2.proto"; 9 | 10 | extend google.protobuf.FileOptions { 11 | // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. 12 | // 13 | // All IDs are the same, as assigned. It is okay that they are the same, as they extend 14 | // different descriptor messages. 15 | Swagger openapiv2_swagger = 1042; 16 | } 17 | extend google.protobuf.MethodOptions { 18 | // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. 19 | // 20 | // All IDs are the same, as assigned. It is okay that they are the same, as they extend 21 | // different descriptor messages. 22 | Operation openapiv2_operation = 1042; 23 | } 24 | extend google.protobuf.MessageOptions { 25 | // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. 26 | // 27 | // All IDs are the same, as assigned. It is okay that they are the same, as they extend 28 | // different descriptor messages. 29 | Schema openapiv2_schema = 1042; 30 | } 31 | extend google.protobuf.ServiceOptions { 32 | // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. 33 | // 34 | // All IDs are the same, as assigned. It is okay that they are the same, as they extend 35 | // different descriptor messages. 36 | Tag openapiv2_tag = 1042; 37 | } 38 | extend google.protobuf.FieldOptions { 39 | // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. 40 | // 41 | // All IDs are the same, as assigned. It is okay that they are the same, as they extend 42 | // different descriptor messages. 43 | JSONSchema openapiv2_field = 1042; 44 | } 45 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GOPATH:=$(shell go env GOPATH) 2 | VERSION=$(shell git describe --tags --always) 3 | INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) 4 | API_PROTO_FILES=$(shell find api -name *.proto) 5 | BUF_INSTALLED := $(shell command -v buf 2> /dev/null) 6 | 7 | ifeq ($(GOHOSTOS), windows) 8 | #the `find.exe` is different from `find` in bash/shell. 9 | #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. 10 | #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git. 11 | Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git))) 12 | INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto") 13 | API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto") 14 | else 15 | INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) 16 | API_PROTO_FILES=$(shell find api -name *.proto) 17 | endif 18 | 19 | .PHONY: init 20 | # init env 21 | init: 22 | go install github.com/go-kratos/kratos/cmd/kratos/v2@a7bae93 23 | go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 24 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0 25 | go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.13.0 26 | go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.13.0 27 | go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@a7bae93 28 | go install github.com/lyouthzzz/protoc-gen-go-errors@v0.0.1 29 | go install github.com/envoyproxy/protoc-gen-validate@v0.9.0 30 | go install github.com/google/wire/cmd/wire@v0.5.0 31 | 32 | .PHONY: api 33 | # generate api proto 34 | api: 35 | protoc --proto_path=. \ 36 | --proto_path=./third_party \ 37 | --go_out=paths=source_relative:. \ 38 | --go-http_out=paths=source_relative:. \ 39 | --go-grpc_out=paths=source_relative:. \ 40 | --go-errors_out=paths=source_relative:. \ 41 | --openapiv2_out=. \ 42 | $(API_PROTO_FILES) 43 | 44 | .PHONY: wire 45 | # wire 46 | wire: 47 | wire ./... 48 | 49 | .PHONY: build 50 | # build 51 | build: 52 | mkdir -p bin/ && GOPROXY="https://goproxy.cn,direct" go build -ldflags '-w -s -extldflags "-static"' -o ./bin/ ./... 53 | 54 | buildimage: 55 | docker build --target api -f Dockerfile -t go-web-layout . -------------------------------------------------------------------------------- /third_party/google/api/httpbody.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/any.proto"; 20 | 21 | option cc_enable_arenas = true; 22 | option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "HttpBodyProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | // Message that represents an arbitrary HTTP body. It should only be used for 29 | // payload formats that can't be represented as JSON, such as raw binary or 30 | // an HTML page. 31 | // 32 | // 33 | // This message can be used both in streaming and non-streaming API methods in 34 | // the request as well as the response. 35 | // 36 | // It can be used as a top-level request field, which is convenient if one 37 | // wants to extract parameters from either the URL or HTTP template into the 38 | // request fields and also want access to the raw HTTP body. 39 | // 40 | // Example: 41 | // 42 | // message GetResourceRequest { 43 | // // A unique request id. 44 | // string request_id = 1; 45 | // 46 | // // The raw HTTP body is bound to this field. 47 | // google.api.HttpBody http_body = 2; 48 | // } 49 | // 50 | // service ResourceService { 51 | // rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); 52 | // rpc UpdateResource(google.api.HttpBody) returns 53 | // (google.protobuf.Empty); 54 | // } 55 | // 56 | // Example with streaming methods: 57 | // 58 | // service CaldavService { 59 | // rpc GetCalendar(stream google.api.HttpBody) 60 | // returns (stream google.api.HttpBody); 61 | // rpc UpdateCalendar(stream google.api.HttpBody) 62 | // returns (stream google.api.HttpBody); 63 | // } 64 | // 65 | // Use of this type only changes how the request and response bodies are 66 | // handled, all other features will continue to work unchanged. 67 | message HttpBody { 68 | // The HTTP Content-Type header value specifying the content type of the body. 69 | string content_type = 1; 70 | 71 | // The HTTP request/response body as raw binary. 72 | bytes data = 2; 73 | 74 | // Application specific response metadata. Must be set in the first response 75 | // for streaming APIs. 76 | repeated google.protobuf.Any extensions = 3; 77 | } 78 | -------------------------------------------------------------------------------- /third_party/google/api/field_behavior.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/descriptor.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "FieldBehaviorProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // An indicator of the behavior of a given field (for example, that a field 29 | // is required in requests, or given as output but ignored as input). 30 | // This **does not** change the behavior in protocol buffers itself; it only 31 | // denotes the behavior and may affect how API tooling handles the field. 32 | // 33 | // Note: This enum **may** receive new values in the future. 34 | enum FieldBehavior { 35 | // Conventional default for enums. Do not use this. 36 | FIELD_BEHAVIOR_UNSPECIFIED = 0; 37 | 38 | // Specifically denotes a field as optional. 39 | // While all fields in protocol buffers are optional, this may be specified 40 | // for emphasis if appropriate. 41 | OPTIONAL = 1; 42 | 43 | // Denotes a field as required. 44 | // This indicates that the field **must** be provided as part of the request, 45 | // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). 46 | REQUIRED = 2; 47 | 48 | // Denotes a field as output only. 49 | // This indicates that the field is provided in responses, but including the 50 | // field in a request does nothing (the server *must* ignore it and 51 | // *must not* throw an error as a result of the field's presence). 52 | OUTPUT_ONLY = 3; 53 | 54 | // Denotes a field as input only. 55 | // This indicates that the field is provided in requests, and the 56 | // corresponding field is not included in output. 57 | INPUT_ONLY = 4; 58 | 59 | // Denotes a field as immutable. 60 | // This indicates that the field may be set once in a request to create a 61 | // resource, but may not be changed thereafter. 62 | IMMUTABLE = 5; 63 | } 64 | 65 | 66 | extend google.protobuf.FieldOptions { 67 | // A designation of a specific field behavior (required, output only, etc.) 68 | // in protobuf messages. 69 | // 70 | // Examples: 71 | // 72 | // string name = 1 [(google.api.field_behavior) = REQUIRED]; 73 | // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 74 | // google.protobuf.Duration ttl = 1 75 | // [(google.api.field_behavior) = INPUT_ONLY]; 76 | // google.protobuf.Timestamp expire_time = 1 77 | // [(google.api.field_behavior) = OUTPUT_ONLY, 78 | // (google.api.field_behavior) = IMMUTABLE]; 79 | repeated FieldBehavior field_behavior = 1052; 80 | } -------------------------------------------------------------------------------- /third_party/google/api/client.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/descriptor.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "ClientProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | extend google.protobuf.ServiceOptions { 29 | // The hostname for this service. 30 | // This should be specified with no prefix or protocol. 31 | // 32 | // Example: 33 | // 34 | // service Foo { 35 | // option (google.api.default_host) = "foo.googleapi.com"; 36 | // ... 37 | // } 38 | string default_host = 1049; 39 | 40 | // OAuth scopes needed for the client. 41 | // 42 | // Example: 43 | // 44 | // service Foo { 45 | // option (google.api.oauth_scopes) = \ 46 | // "https://www.googleapis.com/auth/cloud-platform"; 47 | // ... 48 | // } 49 | // 50 | // If there is more than one scope, use a comma-separated string: 51 | // 52 | // Example: 53 | // 54 | // service Foo { 55 | // option (google.api.oauth_scopes) = \ 56 | // "https://www.googleapis.com/auth/cloud-platform," 57 | // "https://www.googleapis.com/auth/monitoring"; 58 | // ... 59 | // } 60 | string oauth_scopes = 1050; 61 | } 62 | 63 | 64 | extend google.protobuf.MethodOptions { 65 | // A definition of a client library method signature. 66 | // 67 | // In client libraries, each proto RPC corresponds to one or more methods 68 | // which the end user is able to call, and calls the underlying RPC. 69 | // Normally, this method receives a single argument (a struct or instance 70 | // corresponding to the RPC request object). Defining this field will 71 | // add one or more overloads providing flattened or simpler method signatures 72 | // in some languages. 73 | // 74 | // The fields on the method signature are provided as a comma-separated 75 | // string. 76 | // 77 | // For example, the proto RPC and annotation: 78 | // 79 | // rpc CreateSubscription(CreateSubscriptionRequest) 80 | // returns (Subscription) { 81 | // option (google.api.method_signature) = "name,topic"; 82 | // } 83 | // 84 | // Would add the following Java overload (in addition to the method accepting 85 | // the request object): 86 | // 87 | // public final Subscription createSubscription(String name, String topic) 88 | // 89 | // The following backwards-compatibility guidelines apply: 90 | // 91 | // * Adding this annotation to an unannotated method is backwards 92 | // compatible. 93 | // * Adding this annotation to a method which already has existing 94 | // method signature annotations is backwards compatible if and only if 95 | // the new method signature annotation is last in the sequence. 96 | // * Modifying or removing an existing method signature annotation is 97 | // a breaking change. 98 | // * Re-ordering existing method signature annotations is a breaking 99 | // change. 100 | repeated string method_signature = 1051; 101 | } -------------------------------------------------------------------------------- /api/v1/errors.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v3.21.9 5 | // source: api/v1/errors.proto 6 | 7 | package apiV1 8 | 9 | import ( 10 | _ "github.com/go-kratos/kratos/v2/errors" 11 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 12 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 13 | reflect "reflect" 14 | sync "sync" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type ErrorReason int32 25 | 26 | const ( 27 | ErrorReason_UNKNOWN ErrorReason = 0 28 | ErrorReason_NOT_FOUNT ErrorReason = 1 29 | ) 30 | 31 | // Enum value maps for ErrorReason. 32 | var ( 33 | ErrorReason_name = map[int32]string{ 34 | 0: "UNKNOWN", 35 | 1: "NOT_FOUNT", 36 | } 37 | ErrorReason_value = map[string]int32{ 38 | "UNKNOWN": 0, 39 | "NOT_FOUNT": 1, 40 | } 41 | ) 42 | 43 | func (x ErrorReason) Enum() *ErrorReason { 44 | p := new(ErrorReason) 45 | *p = x 46 | return p 47 | } 48 | 49 | func (x ErrorReason) String() string { 50 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) 51 | } 52 | 53 | func (ErrorReason) Descriptor() protoreflect.EnumDescriptor { 54 | return file_api_v1_errors_proto_enumTypes[0].Descriptor() 55 | } 56 | 57 | func (ErrorReason) Type() protoreflect.EnumType { 58 | return &file_api_v1_errors_proto_enumTypes[0] 59 | } 60 | 61 | func (x ErrorReason) Number() protoreflect.EnumNumber { 62 | return protoreflect.EnumNumber(x) 63 | } 64 | 65 | // Deprecated: Use ErrorReason.Descriptor instead. 66 | func (ErrorReason) EnumDescriptor() ([]byte, []int) { 67 | return file_api_v1_errors_proto_rawDescGZIP(), []int{0} 68 | } 69 | 70 | var File_api_v1_errors_proto protoreflect.FileDescriptor 71 | 72 | var file_api_v1_errors_proto_rawDesc = []byte{ 73 | 0x0a, 0x13, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 74 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x13, 0x65, 0x72, 0x72, 0x6f, 75 | 0x72, 0x73, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a, 76 | 0x44, 0x0a, 0x0b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x0b, 77 | 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x09, 0x4e, 78 | 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0x01, 0x1a, 0x04, 0xb0, 0x45, 0x94, 0x03, 79 | 0x1a, 0x13, 0xa0, 0x45, 0xf4, 0x03, 0xaa, 0x45, 0x0c, 0xe6, 0x9c, 0xaa, 0xe7, 0x9f, 0xa5, 0xe9, 80 | 0x94, 0x99, 0xe8, 0xaf, 0xaf, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 81 | 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x79, 0x6f, 0x75, 0x74, 0x68, 0x7a, 0x7a, 0x7a, 0x2f, 0x67, 0x6f, 82 | 0x2d, 0x77, 0x65, 0x62, 0x2d, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 83 | 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 84 | } 85 | 86 | var ( 87 | file_api_v1_errors_proto_rawDescOnce sync.Once 88 | file_api_v1_errors_proto_rawDescData = file_api_v1_errors_proto_rawDesc 89 | ) 90 | 91 | func file_api_v1_errors_proto_rawDescGZIP() []byte { 92 | file_api_v1_errors_proto_rawDescOnce.Do(func() { 93 | file_api_v1_errors_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_v1_errors_proto_rawDescData) 94 | }) 95 | return file_api_v1_errors_proto_rawDescData 96 | } 97 | 98 | var file_api_v1_errors_proto_enumTypes = make([]protoimpl.EnumInfo, 1) 99 | var file_api_v1_errors_proto_goTypes = []interface{}{ 100 | (ErrorReason)(0), // 0: api.ErrorReason 101 | } 102 | var file_api_v1_errors_proto_depIdxs = []int32{ 103 | 0, // [0:0] is the sub-list for method output_type 104 | 0, // [0:0] is the sub-list for method input_type 105 | 0, // [0:0] is the sub-list for extension type_name 106 | 0, // [0:0] is the sub-list for extension extendee 107 | 0, // [0:0] is the sub-list for field type_name 108 | } 109 | 110 | func init() { file_api_v1_errors_proto_init() } 111 | func file_api_v1_errors_proto_init() { 112 | if File_api_v1_errors_proto != nil { 113 | return 114 | } 115 | type x struct{} 116 | out := protoimpl.TypeBuilder{ 117 | File: protoimpl.DescBuilder{ 118 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 119 | RawDescriptor: file_api_v1_errors_proto_rawDesc, 120 | NumEnums: 1, 121 | NumMessages: 0, 122 | NumExtensions: 0, 123 | NumServices: 0, 124 | }, 125 | GoTypes: file_api_v1_errors_proto_goTypes, 126 | DependencyIndexes: file_api_v1_errors_proto_depIdxs, 127 | EnumInfos: file_api_v1_errors_proto_enumTypes, 128 | }.Build() 129 | File_api_v1_errors_proto = out.File 130 | file_api_v1_errors_proto_rawDesc = nil 131 | file_api_v1_errors_proto_goTypes = nil 132 | file_api_v1_errors_proto_depIdxs = nil 133 | } 134 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= 2 | github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k= 3 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/envoyproxy/go-control-plane v0.11.2-0.20230627204322-7d0032219fcb h1:kxNVXsNro/lpR5WD+P1FI/yUHn2G03Glber3k8cQL2Y= 6 | github.com/envoyproxy/protoc-gen-validate v0.10.1 h1:c0g45+xCJhdgFGw7a5QAfdS4byAbud7miNWJ1WwEVf8= 7 | github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= 8 | github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= 9 | github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ= 10 | github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= 11 | github.com/go-kratos/kratos/v2 v2.7.2 h1:WVPGFNLKpv+0odMnCPxM4ZHa2hy9I5FOnwpG3Vv4w5c= 12 | github.com/go-kratos/kratos/v2 v2.7.2/go.mod h1:rppuc8+pGL2UtXA29bgFHWKqaaF6b6GB2XIYiDvFBRk= 13 | github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= 14 | github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= 15 | github.com/go-playground/form/v4 v4.2.0 h1:N1wh+Goz61e6w66vo8vJkQt+uwZSoLz50kZPJWR8eic= 16 | github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= 17 | github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= 18 | github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 19 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 20 | github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= 21 | github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 22 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 23 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 24 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= 25 | github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= 26 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 27 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 28 | github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= 29 | github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= 30 | github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= 31 | github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 32 | github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= 33 | github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= 34 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 35 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 36 | github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= 37 | github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 38 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 39 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 40 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 41 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 42 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 43 | github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= 44 | github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= 45 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 46 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 47 | golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= 48 | golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= 49 | golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= 50 | golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= 51 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 52 | golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 53 | golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= 54 | golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 55 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 56 | golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= 57 | golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 58 | golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 59 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 60 | google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 h1:9JucMWR7sPvCxUFd6UsOUNmA5kCcWOfORaT3tpAsKQs= 61 | google.golang.org/genproto v0.0.0-20230629202037-9506855d4529/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64= 62 | google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1:s5YSX+ZH5b5vS9rnpGymvIyMpLRJizowqDlOuyjXnTk= 63 | google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= 64 | google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529 h1:DEH99RbiLZhMxrpEJCZ0A+wdTe0EOgou/poSLx9vWf4= 65 | google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= 66 | google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= 67 | google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= 68 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 69 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 70 | google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= 71 | google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 72 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 73 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 74 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 75 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 76 | gorm.io/driver/mysql v1.3.3 h1:jXG9ANrwBc4+bMvBcSl8zCfPBaVoPyBEBshA8dA93X8= 77 | gorm.io/driver/mysql v1.3.3/go.mod h1:ChK6AHbHgDCFZyJp0F+BmVGb06PSIoh9uVYKAlRbb2U= 78 | gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= 79 | gorm.io/gorm v1.23.5 h1:TnlF26wScKSvknUC/Rn8t0NLLM22fypYBlvj1+aH6dM= 80 | gorm.io/gorm v1.23.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= 81 | -------------------------------------------------------------------------------- /api/v1/api.swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "title": "api/v1/api.proto", 5 | "version": "version not set" 6 | }, 7 | "tags": [ 8 | { 9 | "name": "UserService" 10 | } 11 | ], 12 | "consumes": [ 13 | "application/json" 14 | ], 15 | "produces": [ 16 | "application/json" 17 | ], 18 | "paths": { 19 | "/users": { 20 | "get": { 21 | "summary": "获取用户列表", 22 | "operationId": "UserService_ListUser", 23 | "responses": { 24 | "200": { 25 | "description": "A successful response.", 26 | "schema": { 27 | "$ref": "#/definitions/v1ListUserReply" 28 | } 29 | }, 30 | "default": { 31 | "description": "An unexpected error response.", 32 | "schema": { 33 | "$ref": "#/definitions/rpcStatus" 34 | } 35 | } 36 | }, 37 | "parameters": [ 38 | { 39 | "name": "offset", 40 | "description": "偏移量", 41 | "in": "query", 42 | "required": false, 43 | "type": "string", 44 | "format": "int64" 45 | }, 46 | { 47 | "name": "limit", 48 | "description": "每页数量", 49 | "in": "query", 50 | "required": false, 51 | "type": "string", 52 | "format": "int64" 53 | } 54 | ], 55 | "tags": [ 56 | "UserService" 57 | ] 58 | }, 59 | "post": { 60 | "summary": "创建用户", 61 | "operationId": "UserService_CreateUser", 62 | "responses": { 63 | "200": { 64 | "description": "A successful response.", 65 | "schema": { 66 | "$ref": "#/definitions/v1Empty" 67 | } 68 | }, 69 | "default": { 70 | "description": "An unexpected error response.", 71 | "schema": { 72 | "$ref": "#/definitions/rpcStatus" 73 | } 74 | } 75 | }, 76 | "parameters": [ 77 | { 78 | "name": "body", 79 | "in": "body", 80 | "required": true, 81 | "schema": { 82 | "$ref": "#/definitions/v1CreateUserRequest" 83 | } 84 | } 85 | ], 86 | "tags": [ 87 | "UserService" 88 | ] 89 | } 90 | }, 91 | "/users/{uid}": { 92 | "get": { 93 | "summary": "获取用户", 94 | "operationId": "UserService_GetUser", 95 | "responses": { 96 | "200": { 97 | "description": "A successful response.", 98 | "schema": { 99 | "$ref": "#/definitions/v1User" 100 | } 101 | }, 102 | "default": { 103 | "description": "An unexpected error response.", 104 | "schema": { 105 | "$ref": "#/definitions/rpcStatus" 106 | } 107 | } 108 | }, 109 | "parameters": [ 110 | { 111 | "name": "uid", 112 | "description": "用户ID", 113 | "in": "path", 114 | "required": true, 115 | "type": "string", 116 | "format": "int64" 117 | } 118 | ], 119 | "tags": [ 120 | "UserService" 121 | ] 122 | }, 123 | "delete": { 124 | "summary": "删除用户", 125 | "operationId": "UserService_DeleteUser", 126 | "responses": { 127 | "200": { 128 | "description": "A successful response.", 129 | "schema": { 130 | "$ref": "#/definitions/v1Empty" 131 | } 132 | }, 133 | "default": { 134 | "description": "An unexpected error response.", 135 | "schema": { 136 | "$ref": "#/definitions/rpcStatus" 137 | } 138 | } 139 | }, 140 | "parameters": [ 141 | { 142 | "name": "uid", 143 | "description": "用户ID", 144 | "in": "path", 145 | "required": true, 146 | "type": "string", 147 | "format": "int64" 148 | } 149 | ], 150 | "tags": [ 151 | "UserService" 152 | ] 153 | }, 154 | "put": { 155 | "summary": "更新用户", 156 | "operationId": "UserService_UpdateUser", 157 | "responses": { 158 | "200": { 159 | "description": "A successful response.", 160 | "schema": { 161 | "$ref": "#/definitions/v1Empty" 162 | } 163 | }, 164 | "default": { 165 | "description": "An unexpected error response.", 166 | "schema": { 167 | "$ref": "#/definitions/rpcStatus" 168 | } 169 | } 170 | }, 171 | "parameters": [ 172 | { 173 | "name": "uid", 174 | "description": "用户ID", 175 | "in": "path", 176 | "required": true, 177 | "type": "string", 178 | "format": "int64" 179 | }, 180 | { 181 | "name": "body", 182 | "in": "body", 183 | "required": true, 184 | "schema": { 185 | "type": "object", 186 | "properties": { 187 | "password": { 188 | "type": "string", 189 | "title": "用户密码" 190 | }, 191 | "email": { 192 | "type": "string", 193 | "title": "用户邮箱" 194 | } 195 | } 196 | } 197 | } 198 | ], 199 | "tags": [ 200 | "UserService" 201 | ] 202 | } 203 | } 204 | }, 205 | "definitions": { 206 | "protobufAny": { 207 | "type": "object", 208 | "properties": { 209 | "@type": { 210 | "type": "string" 211 | } 212 | }, 213 | "additionalProperties": {} 214 | }, 215 | "rpcStatus": { 216 | "type": "object", 217 | "properties": { 218 | "code": { 219 | "type": "integer", 220 | "format": "int32" 221 | }, 222 | "message": { 223 | "type": "string" 224 | }, 225 | "details": { 226 | "type": "array", 227 | "items": { 228 | "$ref": "#/definitions/protobufAny" 229 | } 230 | } 231 | } 232 | }, 233 | "v1CreateUserRequest": { 234 | "type": "object", 235 | "properties": { 236 | "username": { 237 | "type": "string", 238 | "title": "用户名" 239 | }, 240 | "password": { 241 | "type": "string", 242 | "title": "用户密码" 243 | }, 244 | "email": { 245 | "type": "string", 246 | "title": "用户邮箱" 247 | } 248 | } 249 | }, 250 | "v1Empty": { 251 | "type": "object" 252 | }, 253 | "v1ListUserReply": { 254 | "type": "object", 255 | "properties": { 256 | "total": { 257 | "type": "string", 258 | "format": "int64", 259 | "title": "总数" 260 | }, 261 | "items": { 262 | "type": "array", 263 | "items": { 264 | "$ref": "#/definitions/v1User" 265 | }, 266 | "title": "用户列表" 267 | } 268 | } 269 | }, 270 | "v1User": { 271 | "type": "object", 272 | "properties": { 273 | "uid": { 274 | "type": "string", 275 | "format": "int64" 276 | }, 277 | "username": { 278 | "type": "string" 279 | }, 280 | "password": { 281 | "type": "string" 282 | }, 283 | "email": { 284 | "type": "string" 285 | } 286 | } 287 | } 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /api/v1/api_http.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-http. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-http v2.5.3 4 | // - protoc v3.21.9 5 | // source: api/v1/api.proto 6 | 7 | package apiV1 8 | 9 | import ( 10 | context "context" 11 | http "github.com/go-kratos/kratos/v2/transport/http" 12 | binding "github.com/go-kratos/kratos/v2/transport/http/binding" 13 | ) 14 | 15 | // This is a compile-time assertion to ensure that this generated file 16 | // is compatible with the kratos package it is being compiled against. 17 | var _ = new(context.Context) 18 | var _ = binding.EncodeURL 19 | 20 | const _ = http.SupportPackageIsVersion1 21 | 22 | const OperationUserServiceCreateUser = "/user.v1.UserService/CreateUser" 23 | const OperationUserServiceDeleteUser = "/user.v1.UserService/DeleteUser" 24 | const OperationUserServiceGetUser = "/user.v1.UserService/GetUser" 25 | const OperationUserServiceListUser = "/user.v1.UserService/ListUser" 26 | const OperationUserServiceUpdateUser = "/user.v1.UserService/UpdateUser" 27 | 28 | type UserServiceHTTPServer interface { 29 | CreateUser(context.Context, *CreateUserRequest) (*Empty, error) 30 | DeleteUser(context.Context, *DeleteUserRequest) (*Empty, error) 31 | GetUser(context.Context, *GetUserRequest) (*User, error) 32 | ListUser(context.Context, *ListUserRequest) (*ListUserReply, error) 33 | UpdateUser(context.Context, *UpdateUserRequest) (*Empty, error) 34 | } 35 | 36 | func RegisterUserServiceHTTPServer(s *http.Server, srv UserServiceHTTPServer) { 37 | r := s.Route("/") 38 | r.GET("/users/{uid}", _UserService_GetUser0_HTTP_Handler(srv)) 39 | r.POST("/users", _UserService_CreateUser0_HTTP_Handler(srv)) 40 | r.PUT("/users/{uid}", _UserService_UpdateUser0_HTTP_Handler(srv)) 41 | r.DELETE("/users/{uid}", _UserService_DeleteUser0_HTTP_Handler(srv)) 42 | r.GET("/users", _UserService_ListUser0_HTTP_Handler(srv)) 43 | } 44 | 45 | func _UserService_GetUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { 46 | return func(ctx http.Context) error { 47 | var in GetUserRequest 48 | if err := ctx.BindQuery(&in); err != nil { 49 | return err 50 | } 51 | if err := ctx.BindVars(&in); err != nil { 52 | return err 53 | } 54 | http.SetOperation(ctx, OperationUserServiceGetUser) 55 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 56 | return srv.GetUser(ctx, req.(*GetUserRequest)) 57 | }) 58 | out, err := h(ctx, &in) 59 | if err != nil { 60 | return err 61 | } 62 | reply := out.(*User) 63 | return ctx.Result(200, reply) 64 | } 65 | } 66 | 67 | func _UserService_CreateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { 68 | return func(ctx http.Context) error { 69 | var in CreateUserRequest 70 | if err := ctx.Bind(&in); err != nil { 71 | return err 72 | } 73 | http.SetOperation(ctx, OperationUserServiceCreateUser) 74 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 75 | return srv.CreateUser(ctx, req.(*CreateUserRequest)) 76 | }) 77 | out, err := h(ctx, &in) 78 | if err != nil { 79 | return err 80 | } 81 | reply := out.(*Empty) 82 | return ctx.Result(200, reply) 83 | } 84 | } 85 | 86 | func _UserService_UpdateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { 87 | return func(ctx http.Context) error { 88 | var in UpdateUserRequest 89 | if err := ctx.Bind(&in); err != nil { 90 | return err 91 | } 92 | if err := ctx.BindVars(&in); err != nil { 93 | return err 94 | } 95 | http.SetOperation(ctx, OperationUserServiceUpdateUser) 96 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 97 | return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) 98 | }) 99 | out, err := h(ctx, &in) 100 | if err != nil { 101 | return err 102 | } 103 | reply := out.(*Empty) 104 | return ctx.Result(200, reply) 105 | } 106 | } 107 | 108 | func _UserService_DeleteUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { 109 | return func(ctx http.Context) error { 110 | var in DeleteUserRequest 111 | if err := ctx.BindQuery(&in); err != nil { 112 | return err 113 | } 114 | if err := ctx.BindVars(&in); err != nil { 115 | return err 116 | } 117 | http.SetOperation(ctx, OperationUserServiceDeleteUser) 118 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 119 | return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) 120 | }) 121 | out, err := h(ctx, &in) 122 | if err != nil { 123 | return err 124 | } 125 | reply := out.(*Empty) 126 | return ctx.Result(200, reply) 127 | } 128 | } 129 | 130 | func _UserService_ListUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { 131 | return func(ctx http.Context) error { 132 | var in ListUserRequest 133 | if err := ctx.BindQuery(&in); err != nil { 134 | return err 135 | } 136 | http.SetOperation(ctx, OperationUserServiceListUser) 137 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 138 | return srv.ListUser(ctx, req.(*ListUserRequest)) 139 | }) 140 | out, err := h(ctx, &in) 141 | if err != nil { 142 | return err 143 | } 144 | reply := out.(*ListUserReply) 145 | return ctx.Result(200, reply) 146 | } 147 | } 148 | 149 | type UserServiceHTTPClient interface { 150 | CreateUser(ctx context.Context, req *CreateUserRequest, opts ...http.CallOption) (rsp *Empty, err error) 151 | DeleteUser(ctx context.Context, req *DeleteUserRequest, opts ...http.CallOption) (rsp *Empty, err error) 152 | GetUser(ctx context.Context, req *GetUserRequest, opts ...http.CallOption) (rsp *User, err error) 153 | ListUser(ctx context.Context, req *ListUserRequest, opts ...http.CallOption) (rsp *ListUserReply, err error) 154 | UpdateUser(ctx context.Context, req *UpdateUserRequest, opts ...http.CallOption) (rsp *Empty, err error) 155 | } 156 | 157 | type UserServiceHTTPClientImpl struct { 158 | cc *http.Client 159 | } 160 | 161 | func NewUserServiceHTTPClient(client *http.Client) UserServiceHTTPClient { 162 | return &UserServiceHTTPClientImpl{client} 163 | } 164 | 165 | func (c *UserServiceHTTPClientImpl) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...http.CallOption) (*Empty, error) { 166 | var out Empty 167 | pattern := "/users" 168 | path := binding.EncodeURL(pattern, in, false) 169 | opts = append(opts, http.Operation(OperationUserServiceCreateUser)) 170 | opts = append(opts, http.PathTemplate(pattern)) 171 | err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) 172 | if err != nil { 173 | return nil, err 174 | } 175 | return &out, err 176 | } 177 | 178 | func (c *UserServiceHTTPClientImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...http.CallOption) (*Empty, error) { 179 | var out Empty 180 | pattern := "/users/{uid}" 181 | path := binding.EncodeURL(pattern, in, true) 182 | opts = append(opts, http.Operation(OperationUserServiceDeleteUser)) 183 | opts = append(opts, http.PathTemplate(pattern)) 184 | err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) 185 | if err != nil { 186 | return nil, err 187 | } 188 | return &out, err 189 | } 190 | 191 | func (c *UserServiceHTTPClientImpl) GetUser(ctx context.Context, in *GetUserRequest, opts ...http.CallOption) (*User, error) { 192 | var out User 193 | pattern := "/users/{uid}" 194 | path := binding.EncodeURL(pattern, in, true) 195 | opts = append(opts, http.Operation(OperationUserServiceGetUser)) 196 | opts = append(opts, http.PathTemplate(pattern)) 197 | err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) 198 | if err != nil { 199 | return nil, err 200 | } 201 | return &out, err 202 | } 203 | 204 | func (c *UserServiceHTTPClientImpl) ListUser(ctx context.Context, in *ListUserRequest, opts ...http.CallOption) (*ListUserReply, error) { 205 | var out ListUserReply 206 | pattern := "/users" 207 | path := binding.EncodeURL(pattern, in, true) 208 | opts = append(opts, http.Operation(OperationUserServiceListUser)) 209 | opts = append(opts, http.PathTemplate(pattern)) 210 | err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) 211 | if err != nil { 212 | return nil, err 213 | } 214 | return &out, err 215 | } 216 | 217 | func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...http.CallOption) (*Empty, error) { 218 | var out Empty 219 | pattern := "/users/{uid}" 220 | path := binding.EncodeURL(pattern, in, false) 221 | opts = append(opts, http.Operation(OperationUserServiceUpdateUser)) 222 | opts = append(opts, http.PathTemplate(pattern)) 223 | err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) 224 | if err != nil { 225 | return nil, err 226 | } 227 | return &out, err 228 | } 229 | -------------------------------------------------------------------------------- /api/v1/api_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v3.21.9 5 | // source: api/v1/api.proto 6 | 7 | package apiV1 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // UserServiceClient is the client API for UserService service. 22 | // 23 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 24 | type UserServiceClient interface { 25 | // 获取用户 26 | GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*User, error) 27 | // 创建用户 28 | CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*Empty, error) 29 | // 更新用户 30 | UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*Empty, error) 31 | // 删除用户 32 | DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*Empty, error) 33 | // 获取用户列表 34 | ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*ListUserReply, error) 35 | } 36 | 37 | type userServiceClient struct { 38 | cc grpc.ClientConnInterface 39 | } 40 | 41 | func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { 42 | return &userServiceClient{cc} 43 | } 44 | 45 | func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*User, error) { 46 | out := new(User) 47 | err := c.cc.Invoke(ctx, "/user.v1.UserService/GetUser", in, out, opts...) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return out, nil 52 | } 53 | 54 | func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*Empty, error) { 55 | out := new(Empty) 56 | err := c.cc.Invoke(ctx, "/user.v1.UserService/CreateUser", in, out, opts...) 57 | if err != nil { 58 | return nil, err 59 | } 60 | return out, nil 61 | } 62 | 63 | func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*Empty, error) { 64 | out := new(Empty) 65 | err := c.cc.Invoke(ctx, "/user.v1.UserService/UpdateUser", in, out, opts...) 66 | if err != nil { 67 | return nil, err 68 | } 69 | return out, nil 70 | } 71 | 72 | func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*Empty, error) { 73 | out := new(Empty) 74 | err := c.cc.Invoke(ctx, "/user.v1.UserService/DeleteUser", in, out, opts...) 75 | if err != nil { 76 | return nil, err 77 | } 78 | return out, nil 79 | } 80 | 81 | func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*ListUserReply, error) { 82 | out := new(ListUserReply) 83 | err := c.cc.Invoke(ctx, "/user.v1.UserService/ListUser", in, out, opts...) 84 | if err != nil { 85 | return nil, err 86 | } 87 | return out, nil 88 | } 89 | 90 | // UserServiceServer is the server API for UserService service. 91 | // All implementations must embed UnimplementedUserServiceServer 92 | // for forward compatibility 93 | type UserServiceServer interface { 94 | // 获取用户 95 | GetUser(context.Context, *GetUserRequest) (*User, error) 96 | // 创建用户 97 | CreateUser(context.Context, *CreateUserRequest) (*Empty, error) 98 | // 更新用户 99 | UpdateUser(context.Context, *UpdateUserRequest) (*Empty, error) 100 | // 删除用户 101 | DeleteUser(context.Context, *DeleteUserRequest) (*Empty, error) 102 | // 获取用户列表 103 | ListUser(context.Context, *ListUserRequest) (*ListUserReply, error) 104 | mustEmbedUnimplementedUserServiceServer() 105 | } 106 | 107 | // UnimplementedUserServiceServer must be embedded to have forward compatible implementations. 108 | type UnimplementedUserServiceServer struct { 109 | } 110 | 111 | func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*User, error) { 112 | return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") 113 | } 114 | func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*Empty, error) { 115 | return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented") 116 | } 117 | func (UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserRequest) (*Empty, error) { 118 | return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented") 119 | } 120 | func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserRequest) (*Empty, error) { 121 | return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") 122 | } 123 | func (UnimplementedUserServiceServer) ListUser(context.Context, *ListUserRequest) (*ListUserReply, error) { 124 | return nil, status.Errorf(codes.Unimplemented, "method ListUser not implemented") 125 | } 126 | func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} 127 | 128 | // UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. 129 | // Use of this interface is not recommended, as added methods to UserServiceServer will 130 | // result in compilation errors. 131 | type UnsafeUserServiceServer interface { 132 | mustEmbedUnimplementedUserServiceServer() 133 | } 134 | 135 | func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { 136 | s.RegisterService(&UserService_ServiceDesc, srv) 137 | } 138 | 139 | func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 140 | in := new(GetUserRequest) 141 | if err := dec(in); err != nil { 142 | return nil, err 143 | } 144 | if interceptor == nil { 145 | return srv.(UserServiceServer).GetUser(ctx, in) 146 | } 147 | info := &grpc.UnaryServerInfo{ 148 | Server: srv, 149 | FullMethod: "/user.v1.UserService/GetUser", 150 | } 151 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 152 | return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest)) 153 | } 154 | return interceptor(ctx, in, info, handler) 155 | } 156 | 157 | func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 158 | in := new(CreateUserRequest) 159 | if err := dec(in); err != nil { 160 | return nil, err 161 | } 162 | if interceptor == nil { 163 | return srv.(UserServiceServer).CreateUser(ctx, in) 164 | } 165 | info := &grpc.UnaryServerInfo{ 166 | Server: srv, 167 | FullMethod: "/user.v1.UserService/CreateUser", 168 | } 169 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 170 | return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest)) 171 | } 172 | return interceptor(ctx, in, info, handler) 173 | } 174 | 175 | func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 176 | in := new(UpdateUserRequest) 177 | if err := dec(in); err != nil { 178 | return nil, err 179 | } 180 | if interceptor == nil { 181 | return srv.(UserServiceServer).UpdateUser(ctx, in) 182 | } 183 | info := &grpc.UnaryServerInfo{ 184 | Server: srv, 185 | FullMethod: "/user.v1.UserService/UpdateUser", 186 | } 187 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 188 | return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserRequest)) 189 | } 190 | return interceptor(ctx, in, info, handler) 191 | } 192 | 193 | func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 194 | in := new(DeleteUserRequest) 195 | if err := dec(in); err != nil { 196 | return nil, err 197 | } 198 | if interceptor == nil { 199 | return srv.(UserServiceServer).DeleteUser(ctx, in) 200 | } 201 | info := &grpc.UnaryServerInfo{ 202 | Server: srv, 203 | FullMethod: "/user.v1.UserService/DeleteUser", 204 | } 205 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 206 | return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserRequest)) 207 | } 208 | return interceptor(ctx, in, info, handler) 209 | } 210 | 211 | func _UserService_ListUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 212 | in := new(ListUserRequest) 213 | if err := dec(in); err != nil { 214 | return nil, err 215 | } 216 | if interceptor == nil { 217 | return srv.(UserServiceServer).ListUser(ctx, in) 218 | } 219 | info := &grpc.UnaryServerInfo{ 220 | Server: srv, 221 | FullMethod: "/user.v1.UserService/ListUser", 222 | } 223 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 224 | return srv.(UserServiceServer).ListUser(ctx, req.(*ListUserRequest)) 225 | } 226 | return interceptor(ctx, in, info, handler) 227 | } 228 | 229 | // UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. 230 | // It's only intended for direct use with grpc.RegisterService, 231 | // and not to be introspected or modified (even as a copy) 232 | var UserService_ServiceDesc = grpc.ServiceDesc{ 233 | ServiceName: "user.v1.UserService", 234 | HandlerType: (*UserServiceServer)(nil), 235 | Methods: []grpc.MethodDesc{ 236 | { 237 | MethodName: "GetUser", 238 | Handler: _UserService_GetUser_Handler, 239 | }, 240 | { 241 | MethodName: "CreateUser", 242 | Handler: _UserService_CreateUser_Handler, 243 | }, 244 | { 245 | MethodName: "UpdateUser", 246 | Handler: _UserService_UpdateUser_Handler, 247 | }, 248 | { 249 | MethodName: "DeleteUser", 250 | Handler: _UserService_DeleteUser_Handler, 251 | }, 252 | { 253 | MethodName: "ListUser", 254 | Handler: _UserService_ListUser_Handler, 255 | }, 256 | }, 257 | Streams: []grpc.StreamDesc{}, 258 | Metadata: "api/v1/api.proto", 259 | } 260 | -------------------------------------------------------------------------------- /third_party/google/api/http.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option cc_enable_arenas = true; 20 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "HttpProto"; 23 | option java_package = "com.google.api"; 24 | option objc_class_prefix = "GAPI"; 25 | 26 | // Defines the HTTP configuration for an API service. It contains a list of 27 | // [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method 28 | // to one or more HTTP REST API methods. 29 | message Http { 30 | // A list of HTTP configuration rules that apply to individual API methods. 31 | // 32 | // **NOTE:** All service configuration rules follow "last one wins" order. 33 | repeated HttpRule rules = 1; 34 | 35 | // When set to true, URL path parameters will be fully URI-decoded except in 36 | // cases of single segment matches in reserved expansion, where "%2F" will be 37 | // left encoded. 38 | // 39 | // The default behavior is to not decode RFC 6570 reserved characters in multi 40 | // segment matches. 41 | bool fully_decode_reserved_expansion = 2; 42 | } 43 | 44 | // # gRPC Transcoding 45 | // 46 | // gRPC Transcoding is a feature for mapping between a gRPC method and one or 47 | // more HTTP REST endpoints. It allows developers to build a single API service 48 | // that supports both gRPC APIs and REST APIs. Many systems, including [Google 49 | // APIs](https://github.com/googleapis/googleapis), 50 | // [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC 51 | // Gateway](https://github.com/grpc-ecosystem/grpc-gateway), 52 | // and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature 53 | // and use it for large scale production services. 54 | // 55 | // `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies 56 | // how different portions of the gRPC request message are mapped to the URL 57 | // path, URL query parameters, and HTTP request body. It also controls how the 58 | // gRPC response message is mapped to the HTTP response body. `HttpRule` is 59 | // typically specified as an `google.api.http` annotation on the gRPC method. 60 | // 61 | // Each mapping specifies a URL path template and an HTTP method. The path 62 | // template may refer to one or more fields in the gRPC request message, as long 63 | // as each field is a non-repeated field with a primitive (non-message) type. 64 | // The path template controls how fields of the request message are mapped to 65 | // the URL path. 66 | // 67 | // Example: 68 | // 69 | // service Messaging { 70 | // rpc GetMessage(GetMessageRequest) returns (Message) { 71 | // option (google.api.http) = { 72 | // get: "/v1/{name=messages/*}" 73 | // }; 74 | // } 75 | // } 76 | // message GetMessageRequest { 77 | // string name = 1; // Mapped to URL path. 78 | // } 79 | // message Message { 80 | // string text = 1; // The resource content. 81 | // } 82 | // 83 | // This enables an HTTP REST to gRPC mapping as below: 84 | // 85 | // HTTP | gRPC 86 | // -----|----- 87 | // `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` 88 | // 89 | // Any fields in the request message which are not bound by the path template 90 | // automatically become HTTP query parameters if there is no HTTP request body. 91 | // For example: 92 | // 93 | // service Messaging { 94 | // rpc GetMessage(GetMessageRequest) returns (Message) { 95 | // option (google.api.http) = { 96 | // get:"/v1/messages/{message_id}" 97 | // }; 98 | // } 99 | // } 100 | // message GetMessageRequest { 101 | // message SubMessage { 102 | // string subfield = 1; 103 | // } 104 | // string message_id = 1; // Mapped to URL path. 105 | // int64 revision = 2; // Mapped to URL query parameter `revision`. 106 | // SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. 107 | // } 108 | // 109 | // This enables a HTTP JSON to RPC mapping as below: 110 | // 111 | // HTTP | gRPC 112 | // -----|----- 113 | // `GET /v1/messages/123456?revision=2&sub.subfield=foo` | 114 | // `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: 115 | // "foo"))` 116 | // 117 | // Note that fields which are mapped to URL query parameters must have a 118 | // primitive type or a repeated primitive type or a non-repeated message type. 119 | // In the case of a repeated type, the parameter can be repeated in the URL 120 | // as `...?param=A¶m=B`. In the case of a message type, each field of the 121 | // message is mapped to a separate parameter, such as 122 | // `...?foo.a=A&foo.b=B&foo.c=C`. 123 | // 124 | // For HTTP methods that allow a request body, the `body` field 125 | // specifies the mapping. Consider a REST update method on the 126 | // message resource collection: 127 | // 128 | // service Messaging { 129 | // rpc UpdateMessage(UpdateMessageRequest) returns (Message) { 130 | // option (google.api.http) = { 131 | // patch: "/v1/messages/{message_id}" 132 | // body: "message" 133 | // }; 134 | // } 135 | // } 136 | // message UpdateMessageRequest { 137 | // string message_id = 1; // mapped to the URL 138 | // Message message = 2; // mapped to the body 139 | // } 140 | // 141 | // The following HTTP JSON to RPC mapping is enabled, where the 142 | // representation of the JSON in the request body is determined by 143 | // protos JSON encoding: 144 | // 145 | // HTTP | gRPC 146 | // -----|----- 147 | // `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: 148 | // "123456" message { text: "Hi!" })` 149 | // 150 | // The special name `*` can be used in the body mapping to define that 151 | // every field not bound by the path template should be mapped to the 152 | // request body. This enables the following alternative definition of 153 | // the update method: 154 | // 155 | // service Messaging { 156 | // rpc UpdateMessage(Message) returns (Message) { 157 | // option (google.api.http) = { 158 | // patch: "/v1/messages/{message_id}" 159 | // body: "*" 160 | // }; 161 | // } 162 | // } 163 | // message Message { 164 | // string message_id = 1; 165 | // string text = 2; 166 | // } 167 | // 168 | // 169 | // The following HTTP JSON to RPC mapping is enabled: 170 | // 171 | // HTTP | gRPC 172 | // -----|----- 173 | // `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: 174 | // "123456" text: "Hi!")` 175 | // 176 | // Note that when using `*` in the body mapping, it is not possible to 177 | // have HTTP parameters, as all fields not bound by the path end in 178 | // the body. This makes this option more rarely used in practice when 179 | // defining REST APIs. The common usage of `*` is in custom methods 180 | // which don't use the URL at all for transferring data. 181 | // 182 | // It is possible to define multiple HTTP methods for one RPC by using 183 | // the `additional_bindings` option. Example: 184 | // 185 | // service Messaging { 186 | // rpc GetMessage(GetMessageRequest) returns (Message) { 187 | // option (google.api.http) = { 188 | // get: "/v1/messages/{message_id}" 189 | // additional_bindings { 190 | // get: "/v1/users/{user_id}/messages/{message_id}" 191 | // } 192 | // }; 193 | // } 194 | // } 195 | // message GetMessageRequest { 196 | // string message_id = 1; 197 | // string user_id = 2; 198 | // } 199 | // 200 | // This enables the following two alternative HTTP JSON to RPC mappings: 201 | // 202 | // HTTP | gRPC 203 | // -----|----- 204 | // `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` 205 | // `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: 206 | // "123456")` 207 | // 208 | // ## Rules for HTTP mapping 209 | // 210 | // 1. Leaf request fields (recursive expansion nested messages in the request 211 | // message) are classified into three categories: 212 | // - Fields referred by the path template. They are passed via the URL path. 213 | // - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP 214 | // request body. 215 | // - All other fields are passed via the URL query parameters, and the 216 | // parameter name is the field path in the request message. A repeated 217 | // field can be represented as multiple query parameters under the same 218 | // name. 219 | // 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields 220 | // are passed via URL path and HTTP request body. 221 | // 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all 222 | // fields are passed via URL path and URL query parameters. 223 | // 224 | // ### Path template syntax 225 | // 226 | // Template = "/" Segments [ Verb ] ; 227 | // Segments = Segment { "/" Segment } ; 228 | // Segment = "*" | "**" | LITERAL | Variable ; 229 | // Variable = "{" FieldPath [ "=" Segments ] "}" ; 230 | // FieldPath = IDENT { "." IDENT } ; 231 | // Verb = ":" LITERAL ; 232 | // 233 | // The syntax `*` matches a single URL path segment. The syntax `**` matches 234 | // zero or more URL path segments, which must be the last part of the URL path 235 | // except the `Verb`. 236 | // 237 | // The syntax `Variable` matches part of the URL path as specified by its 238 | // template. A variable template must not contain other variables. If a variable 239 | // matches a single path segment, its template may be omitted, e.g. `{var}` 240 | // is equivalent to `{var=*}`. 241 | // 242 | // The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` 243 | // contains any reserved character, such characters should be percent-encoded 244 | // before the matching. 245 | // 246 | // If a variable contains exactly one path segment, such as `"{var}"` or 247 | // `"{var=*}"`, when such a variable is expanded into a URL path on the client 248 | // side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The 249 | // server side does the reverse decoding. Such variables show up in the 250 | // [Discovery 251 | // Document](https://developers.google.com/discovery/v1/reference/apis) as 252 | // `{var}`. 253 | // 254 | // If a variable contains multiple path segments, such as `"{var=foo/*}"` 255 | // or `"{var=**}"`, when such a variable is expanded into a URL path on the 256 | // client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. 257 | // The server side does the reverse decoding, except "%2F" and "%2f" are left 258 | // unchanged. Such variables show up in the 259 | // [Discovery 260 | // Document](https://developers.google.com/discovery/v1/reference/apis) as 261 | // `{+var}`. 262 | // 263 | // ## Using gRPC API Service Configuration 264 | // 265 | // gRPC API Service Configuration (service config) is a configuration language 266 | // for configuring a gRPC service to become a user-facing product. The 267 | // service config is simply the YAML representation of the `google.api.Service` 268 | // proto message. 269 | // 270 | // As an alternative to annotating your proto file, you can configure gRPC 271 | // transcoding in your service config YAML files. You do this by specifying a 272 | // `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same 273 | // effect as the proto annotation. This can be particularly useful if you 274 | // have a proto that is reused in multiple services. Note that any transcoding 275 | // specified in the service config will override any matching transcoding 276 | // configuration in the proto. 277 | // 278 | // Example: 279 | // 280 | // http: 281 | // rules: 282 | // # Selects a gRPC method and applies HttpRule to it. 283 | // - selector: example.v1.Messaging.GetMessage 284 | // get: /v1/messages/{message_id}/{sub.subfield} 285 | // 286 | // ## Special notes 287 | // 288 | // When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the 289 | // proto to JSON conversion must follow the [proto3 290 | // specification](https://developers.google.com/protocol-buffers/docs/proto3#json). 291 | // 292 | // While the single segment variable follows the semantics of 293 | // [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String 294 | // Expansion, the multi segment variable **does not** follow RFC 6570 Section 295 | // 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion 296 | // does not expand special characters like `?` and `#`, which would lead 297 | // to invalid URLs. As the result, gRPC Transcoding uses a custom encoding 298 | // for multi segment variables. 299 | // 300 | // The path variables **must not** refer to any repeated or mapped field, 301 | // because client libraries are not capable of handling such variable expansion. 302 | // 303 | // The path variables **must not** capture the leading "/" character. The reason 304 | // is that the most common use case "{var}" does not capture the leading "/" 305 | // character. For consistency, all path variables must share the same behavior. 306 | // 307 | // Repeated message fields must not be mapped to URL query parameters, because 308 | // no client library can support such complicated mapping. 309 | // 310 | // If an API needs to use a JSON array for request or response body, it can map 311 | // the request or response body to a repeated field. However, some gRPC 312 | // Transcoding implementations may not support this feature. 313 | message HttpRule { 314 | // Selects a method to which this rule applies. 315 | // 316 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 317 | string selector = 1; 318 | 319 | // Determines the URL pattern is matched by this rules. This pattern can be 320 | // used with any of the {get|put|post|delete|patch} methods. A custom method 321 | // can be defined using the 'custom' field. 322 | oneof pattern { 323 | // Maps to HTTP GET. Used for listing and getting information about 324 | // resources. 325 | string get = 2; 326 | 327 | // Maps to HTTP PUT. Used for replacing a resource. 328 | string put = 3; 329 | 330 | // Maps to HTTP POST. Used for creating a resource or performing an action. 331 | string post = 4; 332 | 333 | // Maps to HTTP DELETE. Used for deleting a resource. 334 | string delete = 5; 335 | 336 | // Maps to HTTP PATCH. Used for updating a resource. 337 | string patch = 6; 338 | 339 | // The custom pattern is used for specifying an HTTP method that is not 340 | // included in the `pattern` field, such as HEAD, or "*" to leave the 341 | // HTTP method unspecified for this rule. The wild-card rule is useful 342 | // for services that provide content to Web (HTML) clients. 343 | CustomHttpPattern custom = 8; 344 | } 345 | 346 | // The name of the request field whose value is mapped to the HTTP request 347 | // body, or `*` for mapping all request fields not captured by the path 348 | // pattern to the HTTP body, or omitted for not having any HTTP request body. 349 | // 350 | // NOTE: the referred field must be present at the top-level of the request 351 | // message type. 352 | string body = 7; 353 | 354 | // Optional. The name of the response field whose value is mapped to the HTTP 355 | // response body. When omitted, the entire response message will be used 356 | // as the HTTP response body. 357 | // 358 | // NOTE: The referred field must be present at the top-level of the response 359 | // message type. 360 | string response_body = 12; 361 | 362 | // Additional HTTP bindings for the selector. Nested bindings must 363 | // not contain an `additional_bindings` field themselves (that is, 364 | // the nesting may only be one level deep). 365 | repeated HttpRule additional_bindings = 11; 366 | } 367 | 368 | // A custom pattern is used for defining custom HTTP verb. 369 | message CustomHttpPattern { 370 | // The name of this custom HTTP verb. 371 | string kind = 1; 372 | 373 | // The path matched by this custom verb. 374 | string path = 2; 375 | } 376 | -------------------------------------------------------------------------------- /internal/conf/conf.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.0 4 | // protoc v3.15.5 5 | // source: internal/conf/conf.proto 6 | 7 | package conf 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | durationpb "google.golang.org/protobuf/types/known/durationpb" 13 | reflect "reflect" 14 | sync "sync" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type Bootstrap struct { 25 | state protoimpl.MessageState 26 | sizeCache protoimpl.SizeCache 27 | unknownFields protoimpl.UnknownFields 28 | 29 | Server *Server `protobuf:"bytes,2,opt,name=server,proto3" json:"server,omitempty"` 30 | Data *Data `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` 31 | } 32 | 33 | func (x *Bootstrap) Reset() { 34 | *x = Bootstrap{} 35 | if protoimpl.UnsafeEnabled { 36 | mi := &file_internal_conf_conf_proto_msgTypes[0] 37 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 38 | ms.StoreMessageInfo(mi) 39 | } 40 | } 41 | 42 | func (x *Bootstrap) String() string { 43 | return protoimpl.X.MessageStringOf(x) 44 | } 45 | 46 | func (*Bootstrap) ProtoMessage() {} 47 | 48 | func (x *Bootstrap) ProtoReflect() protoreflect.Message { 49 | mi := &file_internal_conf_conf_proto_msgTypes[0] 50 | if protoimpl.UnsafeEnabled && x != nil { 51 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 52 | if ms.LoadMessageInfo() == nil { 53 | ms.StoreMessageInfo(mi) 54 | } 55 | return ms 56 | } 57 | return mi.MessageOf(x) 58 | } 59 | 60 | // Deprecated: Use Bootstrap.ProtoReflect.Descriptor instead. 61 | func (*Bootstrap) Descriptor() ([]byte, []int) { 62 | return file_internal_conf_conf_proto_rawDescGZIP(), []int{0} 63 | } 64 | 65 | func (x *Bootstrap) GetServer() *Server { 66 | if x != nil { 67 | return x.Server 68 | } 69 | return nil 70 | } 71 | 72 | func (x *Bootstrap) GetData() *Data { 73 | if x != nil { 74 | return x.Data 75 | } 76 | return nil 77 | } 78 | 79 | type Server struct { 80 | state protoimpl.MessageState 81 | sizeCache protoimpl.SizeCache 82 | unknownFields protoimpl.UnknownFields 83 | 84 | Http *Server_HTTP `protobuf:"bytes,1,opt,name=http,proto3" json:"http,omitempty"` 85 | Grpc *Server_GRPC `protobuf:"bytes,2,opt,name=grpc,proto3" json:"grpc,omitempty"` 86 | } 87 | 88 | func (x *Server) Reset() { 89 | *x = Server{} 90 | if protoimpl.UnsafeEnabled { 91 | mi := &file_internal_conf_conf_proto_msgTypes[1] 92 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 93 | ms.StoreMessageInfo(mi) 94 | } 95 | } 96 | 97 | func (x *Server) String() string { 98 | return protoimpl.X.MessageStringOf(x) 99 | } 100 | 101 | func (*Server) ProtoMessage() {} 102 | 103 | func (x *Server) ProtoReflect() protoreflect.Message { 104 | mi := &file_internal_conf_conf_proto_msgTypes[1] 105 | if protoimpl.UnsafeEnabled && x != nil { 106 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 107 | if ms.LoadMessageInfo() == nil { 108 | ms.StoreMessageInfo(mi) 109 | } 110 | return ms 111 | } 112 | return mi.MessageOf(x) 113 | } 114 | 115 | // Deprecated: Use Server.ProtoReflect.Descriptor instead. 116 | func (*Server) Descriptor() ([]byte, []int) { 117 | return file_internal_conf_conf_proto_rawDescGZIP(), []int{1} 118 | } 119 | 120 | func (x *Server) GetHttp() *Server_HTTP { 121 | if x != nil { 122 | return x.Http 123 | } 124 | return nil 125 | } 126 | 127 | func (x *Server) GetGrpc() *Server_GRPC { 128 | if x != nil { 129 | return x.Grpc 130 | } 131 | return nil 132 | } 133 | 134 | type Data struct { 135 | state protoimpl.MessageState 136 | sizeCache protoimpl.SizeCache 137 | unknownFields protoimpl.UnknownFields 138 | 139 | Database *Data_Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` 140 | } 141 | 142 | func (x *Data) Reset() { 143 | *x = Data{} 144 | if protoimpl.UnsafeEnabled { 145 | mi := &file_internal_conf_conf_proto_msgTypes[2] 146 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 147 | ms.StoreMessageInfo(mi) 148 | } 149 | } 150 | 151 | func (x *Data) String() string { 152 | return protoimpl.X.MessageStringOf(x) 153 | } 154 | 155 | func (*Data) ProtoMessage() {} 156 | 157 | func (x *Data) ProtoReflect() protoreflect.Message { 158 | mi := &file_internal_conf_conf_proto_msgTypes[2] 159 | if protoimpl.UnsafeEnabled && x != nil { 160 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 161 | if ms.LoadMessageInfo() == nil { 162 | ms.StoreMessageInfo(mi) 163 | } 164 | return ms 165 | } 166 | return mi.MessageOf(x) 167 | } 168 | 169 | // Deprecated: Use Data.ProtoReflect.Descriptor instead. 170 | func (*Data) Descriptor() ([]byte, []int) { 171 | return file_internal_conf_conf_proto_rawDescGZIP(), []int{2} 172 | } 173 | 174 | func (x *Data) GetDatabase() *Data_Database { 175 | if x != nil { 176 | return x.Database 177 | } 178 | return nil 179 | } 180 | 181 | type Server_HTTP struct { 182 | state protoimpl.MessageState 183 | sizeCache protoimpl.SizeCache 184 | unknownFields protoimpl.UnknownFields 185 | 186 | Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` 187 | Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` 188 | Timeout *durationpb.Duration `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout,omitempty"` 189 | } 190 | 191 | func (x *Server_HTTP) Reset() { 192 | *x = Server_HTTP{} 193 | if protoimpl.UnsafeEnabled { 194 | mi := &file_internal_conf_conf_proto_msgTypes[3] 195 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 196 | ms.StoreMessageInfo(mi) 197 | } 198 | } 199 | 200 | func (x *Server_HTTP) String() string { 201 | return protoimpl.X.MessageStringOf(x) 202 | } 203 | 204 | func (*Server_HTTP) ProtoMessage() {} 205 | 206 | func (x *Server_HTTP) ProtoReflect() protoreflect.Message { 207 | mi := &file_internal_conf_conf_proto_msgTypes[3] 208 | if protoimpl.UnsafeEnabled && x != nil { 209 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 210 | if ms.LoadMessageInfo() == nil { 211 | ms.StoreMessageInfo(mi) 212 | } 213 | return ms 214 | } 215 | return mi.MessageOf(x) 216 | } 217 | 218 | // Deprecated: Use Server_HTTP.ProtoReflect.Descriptor instead. 219 | func (*Server_HTTP) Descriptor() ([]byte, []int) { 220 | return file_internal_conf_conf_proto_rawDescGZIP(), []int{1, 0} 221 | } 222 | 223 | func (x *Server_HTTP) GetNetwork() string { 224 | if x != nil { 225 | return x.Network 226 | } 227 | return "" 228 | } 229 | 230 | func (x *Server_HTTP) GetAddr() string { 231 | if x != nil { 232 | return x.Addr 233 | } 234 | return "" 235 | } 236 | 237 | func (x *Server_HTTP) GetTimeout() *durationpb.Duration { 238 | if x != nil { 239 | return x.Timeout 240 | } 241 | return nil 242 | } 243 | 244 | type Server_GRPC struct { 245 | state protoimpl.MessageState 246 | sizeCache protoimpl.SizeCache 247 | unknownFields protoimpl.UnknownFields 248 | 249 | Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` 250 | Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` 251 | Timeout *durationpb.Duration `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout,omitempty"` 252 | } 253 | 254 | func (x *Server_GRPC) Reset() { 255 | *x = Server_GRPC{} 256 | if protoimpl.UnsafeEnabled { 257 | mi := &file_internal_conf_conf_proto_msgTypes[4] 258 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 259 | ms.StoreMessageInfo(mi) 260 | } 261 | } 262 | 263 | func (x *Server_GRPC) String() string { 264 | return protoimpl.X.MessageStringOf(x) 265 | } 266 | 267 | func (*Server_GRPC) ProtoMessage() {} 268 | 269 | func (x *Server_GRPC) ProtoReflect() protoreflect.Message { 270 | mi := &file_internal_conf_conf_proto_msgTypes[4] 271 | if protoimpl.UnsafeEnabled && x != nil { 272 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 273 | if ms.LoadMessageInfo() == nil { 274 | ms.StoreMessageInfo(mi) 275 | } 276 | return ms 277 | } 278 | return mi.MessageOf(x) 279 | } 280 | 281 | // Deprecated: Use Server_GRPC.ProtoReflect.Descriptor instead. 282 | func (*Server_GRPC) Descriptor() ([]byte, []int) { 283 | return file_internal_conf_conf_proto_rawDescGZIP(), []int{1, 1} 284 | } 285 | 286 | func (x *Server_GRPC) GetNetwork() string { 287 | if x != nil { 288 | return x.Network 289 | } 290 | return "" 291 | } 292 | 293 | func (x *Server_GRPC) GetAddr() string { 294 | if x != nil { 295 | return x.Addr 296 | } 297 | return "" 298 | } 299 | 300 | func (x *Server_GRPC) GetTimeout() *durationpb.Duration { 301 | if x != nil { 302 | return x.Timeout 303 | } 304 | return nil 305 | } 306 | 307 | type Data_Database struct { 308 | state protoimpl.MessageState 309 | sizeCache protoimpl.SizeCache 310 | unknownFields protoimpl.UnknownFields 311 | 312 | Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` 313 | Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` 314 | } 315 | 316 | func (x *Data_Database) Reset() { 317 | *x = Data_Database{} 318 | if protoimpl.UnsafeEnabled { 319 | mi := &file_internal_conf_conf_proto_msgTypes[5] 320 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 321 | ms.StoreMessageInfo(mi) 322 | } 323 | } 324 | 325 | func (x *Data_Database) String() string { 326 | return protoimpl.X.MessageStringOf(x) 327 | } 328 | 329 | func (*Data_Database) ProtoMessage() {} 330 | 331 | func (x *Data_Database) ProtoReflect() protoreflect.Message { 332 | mi := &file_internal_conf_conf_proto_msgTypes[5] 333 | if protoimpl.UnsafeEnabled && x != nil { 334 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 335 | if ms.LoadMessageInfo() == nil { 336 | ms.StoreMessageInfo(mi) 337 | } 338 | return ms 339 | } 340 | return mi.MessageOf(x) 341 | } 342 | 343 | // Deprecated: Use Data_Database.ProtoReflect.Descriptor instead. 344 | func (*Data_Database) Descriptor() ([]byte, []int) { 345 | return file_internal_conf_conf_proto_rawDescGZIP(), []int{2, 0} 346 | } 347 | 348 | func (x *Data_Database) GetDriver() string { 349 | if x != nil { 350 | return x.Driver 351 | } 352 | return "" 353 | } 354 | 355 | func (x *Data_Database) GetSource() string { 356 | if x != nil { 357 | return x.Source 358 | } 359 | return "" 360 | } 361 | 362 | var File_internal_conf_conf_proto protoreflect.FileDescriptor 363 | 364 | var file_internal_conf_conf_proto_rawDesc = []byte{ 365 | 0x0a, 0x18, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 366 | 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x77, 0x65, 0x62, 0x6c, 367 | 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x1e, 0x67, 0x6f, 368 | 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 369 | 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x69, 0x0a, 0x09, 370 | 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x65, 0x72, 371 | 0x76, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x77, 0x65, 0x62, 0x6c, 372 | 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x53, 0x65, 0x72, 373 | 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x04, 0x64, 374 | 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x77, 0x65, 0x62, 0x6c, 375 | 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x61, 0x74, 376 | 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xc4, 0x02, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 377 | 0x65, 0x72, 0x12, 0x31, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 378 | 0x32, 0x1d, 0x2e, 0x77, 0x65, 0x62, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 379 | 0x66, 0x69, 0x67, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x52, 380 | 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 0x31, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x02, 0x20, 381 | 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x77, 0x65, 0x62, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2e, 382 | 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x52, 383 | 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x1a, 0x69, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 384 | 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 385 | 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 386 | 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x33, 387 | 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 388 | 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 389 | 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 390 | 0x6f, 0x75, 0x74, 0x1a, 0x69, 0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x12, 0x18, 0x0a, 0x07, 0x6e, 391 | 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 392 | 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 393 | 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 394 | 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 395 | 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 396 | 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x7f, 397 | 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3b, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 398 | 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x77, 0x65, 0x62, 0x6c, 0x61, 399 | 0x79, 0x6f, 0x75, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x61, 0x74, 0x61, 400 | 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 401 | 0x61, 0x73, 0x65, 0x1a, 0x3a, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 402 | 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 403 | 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 404 | 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 405 | 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x79, 406 | 0x6f, 0x75, 0x74, 0x68, 0x7a, 0x7a, 0x7a, 0x2f, 0x67, 0x6f, 0x2d, 0x77, 0x65, 0x62, 0x2d, 0x6c, 407 | 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 408 | 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 409 | } 410 | 411 | var ( 412 | file_internal_conf_conf_proto_rawDescOnce sync.Once 413 | file_internal_conf_conf_proto_rawDescData = file_internal_conf_conf_proto_rawDesc 414 | ) 415 | 416 | func file_internal_conf_conf_proto_rawDescGZIP() []byte { 417 | file_internal_conf_conf_proto_rawDescOnce.Do(func() { 418 | file_internal_conf_conf_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_conf_conf_proto_rawDescData) 419 | }) 420 | return file_internal_conf_conf_proto_rawDescData 421 | } 422 | 423 | var file_internal_conf_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 6) 424 | var file_internal_conf_conf_proto_goTypes = []interface{}{ 425 | (*Bootstrap)(nil), // 0: weblayout.config.Bootstrap 426 | (*Server)(nil), // 1: weblayout.config.Server 427 | (*Data)(nil), // 2: weblayout.config.Data 428 | (*Server_HTTP)(nil), // 3: weblayout.config.Server.HTTP 429 | (*Server_GRPC)(nil), // 4: weblayout.config.Server.GRPC 430 | (*Data_Database)(nil), // 5: weblayout.config.Data.Database 431 | (*durationpb.Duration)(nil), // 6: google.protobuf.Duration 432 | } 433 | var file_internal_conf_conf_proto_depIdxs = []int32{ 434 | 1, // 0: weblayout.config.Bootstrap.server:type_name -> weblayout.config.Server 435 | 2, // 1: weblayout.config.Bootstrap.data:type_name -> weblayout.config.Data 436 | 3, // 2: weblayout.config.Server.http:type_name -> weblayout.config.Server.HTTP 437 | 4, // 3: weblayout.config.Server.grpc:type_name -> weblayout.config.Server.GRPC 438 | 5, // 4: weblayout.config.Data.database:type_name -> weblayout.config.Data.Database 439 | 6, // 5: weblayout.config.Server.HTTP.timeout:type_name -> google.protobuf.Duration 440 | 6, // 6: weblayout.config.Server.GRPC.timeout:type_name -> google.protobuf.Duration 441 | 7, // [7:7] is the sub-list for method output_type 442 | 7, // [7:7] is the sub-list for method input_type 443 | 7, // [7:7] is the sub-list for extension type_name 444 | 7, // [7:7] is the sub-list for extension extendee 445 | 0, // [0:7] is the sub-list for field type_name 446 | } 447 | 448 | func init() { file_internal_conf_conf_proto_init() } 449 | func file_internal_conf_conf_proto_init() { 450 | if File_internal_conf_conf_proto != nil { 451 | return 452 | } 453 | if !protoimpl.UnsafeEnabled { 454 | file_internal_conf_conf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 455 | switch v := v.(*Bootstrap); i { 456 | case 0: 457 | return &v.state 458 | case 1: 459 | return &v.sizeCache 460 | case 2: 461 | return &v.unknownFields 462 | default: 463 | return nil 464 | } 465 | } 466 | file_internal_conf_conf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 467 | switch v := v.(*Server); i { 468 | case 0: 469 | return &v.state 470 | case 1: 471 | return &v.sizeCache 472 | case 2: 473 | return &v.unknownFields 474 | default: 475 | return nil 476 | } 477 | } 478 | file_internal_conf_conf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 479 | switch v := v.(*Data); i { 480 | case 0: 481 | return &v.state 482 | case 1: 483 | return &v.sizeCache 484 | case 2: 485 | return &v.unknownFields 486 | default: 487 | return nil 488 | } 489 | } 490 | file_internal_conf_conf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 491 | switch v := v.(*Server_HTTP); i { 492 | case 0: 493 | return &v.state 494 | case 1: 495 | return &v.sizeCache 496 | case 2: 497 | return &v.unknownFields 498 | default: 499 | return nil 500 | } 501 | } 502 | file_internal_conf_conf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 503 | switch v := v.(*Server_GRPC); i { 504 | case 0: 505 | return &v.state 506 | case 1: 507 | return &v.sizeCache 508 | case 2: 509 | return &v.unknownFields 510 | default: 511 | return nil 512 | } 513 | } 514 | file_internal_conf_conf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 515 | switch v := v.(*Data_Database); i { 516 | case 0: 517 | return &v.state 518 | case 1: 519 | return &v.sizeCache 520 | case 2: 521 | return &v.unknownFields 522 | default: 523 | return nil 524 | } 525 | } 526 | } 527 | type x struct{} 528 | out := protoimpl.TypeBuilder{ 529 | File: protoimpl.DescBuilder{ 530 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 531 | RawDescriptor: file_internal_conf_conf_proto_rawDesc, 532 | NumEnums: 0, 533 | NumMessages: 6, 534 | NumExtensions: 0, 535 | NumServices: 0, 536 | }, 537 | GoTypes: file_internal_conf_conf_proto_goTypes, 538 | DependencyIndexes: file_internal_conf_conf_proto_depIdxs, 539 | MessageInfos: file_internal_conf_conf_proto_msgTypes, 540 | }.Build() 541 | File_internal_conf_conf_proto = out.File 542 | file_internal_conf_conf_proto_rawDesc = nil 543 | file_internal_conf_conf_proto_goTypes = nil 544 | file_internal_conf_conf_proto_depIdxs = nil 545 | } 546 | -------------------------------------------------------------------------------- /third_party/protoc-gen-openapiv2/options/openapiv2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package grpc.gateway.protoc_gen_openapiv2.options; 4 | 5 | option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; 6 | 7 | import "google/protobuf/struct.proto"; 8 | 9 | // Scheme describes the schemes supported by the OpenAPI Swagger 10 | // and Operation objects. 11 | enum Scheme { 12 | UNKNOWN = 0; 13 | HTTP = 1; 14 | HTTPS = 2; 15 | WS = 3; 16 | WSS = 4; 17 | } 18 | 19 | // `Swagger` is a representation of OpenAPI v2 specification's Swagger object. 20 | // 21 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject 22 | // 23 | // Example: 24 | // 25 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { 26 | // info: { 27 | // title: "Echo API"; 28 | // version: "1.0"; 29 | // description: "; 30 | // contact: { 31 | // name: "gRPC-Gateway project"; 32 | // url: "https://github.com/grpc-ecosystem/grpc-gateway"; 33 | // email: "none@example.com"; 34 | // }; 35 | // license: { 36 | // name: "BSD 3-Clause License"; 37 | // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; 38 | // }; 39 | // }; 40 | // schemes: HTTPS; 41 | // consumes: "application/json"; 42 | // produces: "application/json"; 43 | // }; 44 | // 45 | message Swagger { 46 | // Specifies the OpenAPI Specification version being used. It can be 47 | // used by the OpenAPI UI and other clients to interpret the API listing. The 48 | // value MUST be "2.0". 49 | string swagger = 1; 50 | // Provides metadata about the API. The metadata can be used by the 51 | // clients if needed. 52 | Info info = 2; 53 | // The host (name or ip) serving the API. This MUST be the host only and does 54 | // not include the scheme nor sub-paths. It MAY include a port. If the host is 55 | // not included, the host serving the documentation is to be used (including 56 | // the port). The host does not support path templating. 57 | string host = 3; 58 | // The base path on which the API is served, which is relative to the host. If 59 | // it is not included, the API is served directly under the host. The value 60 | // MUST start with a leading slash (/). The basePath does not support path 61 | // templating. 62 | // Note that using `base_path` does not change the endpoint paths that are 63 | // generated in the resulting OpenAPI file. If you wish to use `base_path` 64 | // with relatively generated OpenAPI paths, the `base_path` prefix must be 65 | // manually removed from your `google.api.http` paths and your code changed to 66 | // serve the API from the `base_path`. 67 | string base_path = 4; 68 | // The transfer protocol of the API. Values MUST be from the list: "http", 69 | // "https", "ws", "wss". If the schemes is not included, the default scheme to 70 | // be used is the one used to access the OpenAPI definition itself. 71 | repeated Scheme schemes = 5; 72 | // A list of MIME types the APIs can consume. This is global to all APIs but 73 | // can be overridden on specific API calls. Value MUST be as described under 74 | // Mime Types. 75 | repeated string consumes = 6; 76 | // A list of MIME types the APIs can produce. This is global to all APIs but 77 | // can be overridden on specific API calls. Value MUST be as described under 78 | // Mime Types. 79 | repeated string produces = 7; 80 | // field 8 is reserved for 'paths'. 81 | reserved 8; 82 | // field 9 is reserved for 'definitions', which at this time are already 83 | // exposed as and customizable as proto messages. 84 | reserved 9; 85 | // An object to hold responses that can be used across operations. This 86 | // property does not define global responses for all operations. 87 | map responses = 10; 88 | // Security scheme definitions that can be used across the specification. 89 | SecurityDefinitions security_definitions = 11; 90 | // A declaration of which security schemes are applied for the API as a whole. 91 | // The list of values describes alternative security schemes that can be used 92 | // (that is, there is a logical OR between the security requirements). 93 | // Individual operations can override this definition. 94 | repeated SecurityRequirement security = 12; 95 | // field 13 is reserved for 'tags', which are supposed to be exposed as and 96 | // customizable as proto services. TODO(ivucica): add processing of proto 97 | // service objects into OpenAPI v2 Tag objects. 98 | reserved 13; 99 | // Additional external documentation. 100 | ExternalDocumentation external_docs = 14; 101 | map extensions = 15; 102 | } 103 | 104 | // `Operation` is a representation of OpenAPI v2 specification's Operation object. 105 | // 106 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject 107 | // 108 | // Example: 109 | // 110 | // service EchoService { 111 | // rpc Echo(SimpleMessage) returns (SimpleMessage) { 112 | // option (google.api.http) = { 113 | // get: "/v1/example/echo/{id}" 114 | // }; 115 | // 116 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { 117 | // summary: "Get a message."; 118 | // operation_id: "getMessage"; 119 | // tags: "echo"; 120 | // responses: { 121 | // key: "200" 122 | // value: { 123 | // description: "OK"; 124 | // } 125 | // } 126 | // }; 127 | // } 128 | // } 129 | message Operation { 130 | // A list of tags for API documentation control. Tags can be used for logical 131 | // grouping of operations by resources or any other qualifier. 132 | repeated string tags = 1; 133 | // A short summary of what the operation does. For maximum readability in the 134 | // swagger-ui, this field SHOULD be less than 120 characters. 135 | string summary = 2; 136 | // A verbose explanation of the operation behavior. GFM syntax can be used for 137 | // rich text representation. 138 | string description = 3; 139 | // Additional external documentation for this operation. 140 | ExternalDocumentation external_docs = 4; 141 | // Unique string used to identify the operation. The id MUST be unique among 142 | // all operations described in the API. Tools and libraries MAY use the 143 | // operationId to uniquely identify an operation, therefore, it is recommended 144 | // to follow common programming naming conventions. 145 | string operation_id = 5; 146 | // A list of MIME types the operation can consume. This overrides the consumes 147 | // definition at the OpenAPI Object. An empty value MAY be used to clear the 148 | // global definition. Value MUST be as described under Mime Types. 149 | repeated string consumes = 6; 150 | // A list of MIME types the operation can produce. This overrides the produces 151 | // definition at the OpenAPI Object. An empty value MAY be used to clear the 152 | // global definition. Value MUST be as described under Mime Types. 153 | repeated string produces = 7; 154 | // field 8 is reserved for 'parameters'. 155 | reserved 8; 156 | // The list of possible responses as they are returned from executing this 157 | // operation. 158 | map responses = 9; 159 | // The transfer protocol for the operation. Values MUST be from the list: 160 | // "http", "https", "ws", "wss". The value overrides the OpenAPI Object 161 | // schemes definition. 162 | repeated Scheme schemes = 10; 163 | // Declares this operation to be deprecated. Usage of the declared operation 164 | // should be refrained. Default value is false. 165 | bool deprecated = 11; 166 | // A declaration of which security schemes are applied for this operation. The 167 | // list of values describes alternative security schemes that can be used 168 | // (that is, there is a logical OR between the security requirements). This 169 | // definition overrides any declared top-level security. To remove a top-level 170 | // security declaration, an empty array can be used. 171 | repeated SecurityRequirement security = 12; 172 | map extensions = 13; 173 | } 174 | 175 | // `Header` is a representation of OpenAPI v2 specification's Header object. 176 | // 177 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject 178 | // 179 | message Header { 180 | // `Description` is a short description of the header. 181 | string description = 1; 182 | // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. 183 | string type = 2; 184 | // `Format` The extending format for the previously mentioned type. 185 | string format = 3; 186 | // field 4 is reserved for 'items', but in OpenAPI-specific way. 187 | reserved 4; 188 | // field 5 is reserved `Collection Format` Determines the format of the array if type array is used. 189 | reserved 5; 190 | // `Default` Declares the value of the header that the server will use if none is provided. 191 | // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. 192 | // Unlike JSON Schema this value MUST conform to the defined type for the header. 193 | string default = 6; 194 | // field 7 is reserved for 'maximum'. 195 | reserved 7; 196 | // field 8 is reserved for 'exclusiveMaximum'. 197 | reserved 8; 198 | // field 9 is reserved for 'minimum'. 199 | reserved 9; 200 | // field 10 is reserved for 'exclusiveMinimum'. 201 | reserved 10; 202 | // field 11 is reserved for 'maxLength'. 203 | reserved 11; 204 | // field 12 is reserved for 'minLength'. 205 | reserved 12; 206 | // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. 207 | string pattern = 13; 208 | // field 14 is reserved for 'maxItems'. 209 | reserved 14; 210 | // field 15 is reserved for 'minItems'. 211 | reserved 15; 212 | // field 16 is reserved for 'uniqueItems'. 213 | reserved 16; 214 | // field 17 is reserved for 'enum'. 215 | reserved 17; 216 | // field 18 is reserved for 'multipleOf'. 217 | reserved 18; 218 | } 219 | 220 | // `Response` is a representation of OpenAPI v2 specification's Response object. 221 | // 222 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject 223 | // 224 | message Response { 225 | // `Description` is a short description of the response. 226 | // GFM syntax can be used for rich text representation. 227 | string description = 1; 228 | // `Schema` optionally defines the structure of the response. 229 | // If `Schema` is not provided, it means there is no content to the response. 230 | Schema schema = 2; 231 | // `Headers` A list of headers that are sent with the response. 232 | // `Header` name is expected to be a string in the canonical format of the MIME header key 233 | // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey 234 | map headers = 3; 235 | // `Examples` gives per-mimetype response examples. 236 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object 237 | map examples = 4; 238 | map extensions = 5; 239 | } 240 | 241 | // `Info` is a representation of OpenAPI v2 specification's Info object. 242 | // 243 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject 244 | // 245 | // Example: 246 | // 247 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { 248 | // info: { 249 | // title: "Echo API"; 250 | // version: "1.0"; 251 | // description: "; 252 | // contact: { 253 | // name: "gRPC-Gateway project"; 254 | // url: "https://github.com/grpc-ecosystem/grpc-gateway"; 255 | // email: "none@example.com"; 256 | // }; 257 | // license: { 258 | // name: "BSD 3-Clause License"; 259 | // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; 260 | // }; 261 | // }; 262 | // ... 263 | // }; 264 | // 265 | message Info { 266 | // The title of the application. 267 | string title = 1; 268 | // A short description of the application. GFM syntax can be used for rich 269 | // text representation. 270 | string description = 2; 271 | // The Terms of Service for the API. 272 | string terms_of_service = 3; 273 | // The contact information for the exposed API. 274 | Contact contact = 4; 275 | // The license information for the exposed API. 276 | License license = 5; 277 | // Provides the version of the application API (not to be confused 278 | // with the specification version). 279 | string version = 6; 280 | map extensions = 7; 281 | } 282 | 283 | // `Contact` is a representation of OpenAPI v2 specification's Contact object. 284 | // 285 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject 286 | // 287 | // Example: 288 | // 289 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { 290 | // info: { 291 | // ... 292 | // contact: { 293 | // name: "gRPC-Gateway project"; 294 | // url: "https://github.com/grpc-ecosystem/grpc-gateway"; 295 | // email: "none@example.com"; 296 | // }; 297 | // ... 298 | // }; 299 | // ... 300 | // }; 301 | // 302 | message Contact { 303 | // The identifying name of the contact person/organization. 304 | string name = 1; 305 | // The URL pointing to the contact information. MUST be in the format of a 306 | // URL. 307 | string url = 2; 308 | // The email address of the contact person/organization. MUST be in the format 309 | // of an email address. 310 | string email = 3; 311 | } 312 | 313 | // `License` is a representation of OpenAPI v2 specification's License object. 314 | // 315 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject 316 | // 317 | // Example: 318 | // 319 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { 320 | // info: { 321 | // ... 322 | // license: { 323 | // name: "BSD 3-Clause License"; 324 | // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"; 325 | // }; 326 | // ... 327 | // }; 328 | // ... 329 | // }; 330 | // 331 | message License { 332 | // The license name used for the API. 333 | string name = 1; 334 | // A URL to the license used for the API. MUST be in the format of a URL. 335 | string url = 2; 336 | } 337 | 338 | // `ExternalDocumentation` is a representation of OpenAPI v2 specification's 339 | // ExternalDocumentation object. 340 | // 341 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject 342 | // 343 | // Example: 344 | // 345 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { 346 | // ... 347 | // external_docs: { 348 | // description: "More about gRPC-Gateway"; 349 | // url: "https://github.com/grpc-ecosystem/grpc-gateway"; 350 | // } 351 | // ... 352 | // }; 353 | // 354 | message ExternalDocumentation { 355 | // A short description of the target documentation. GFM syntax can be used for 356 | // rich text representation. 357 | string description = 1; 358 | // The URL for the target documentation. Value MUST be in the format 359 | // of a URL. 360 | string url = 2; 361 | } 362 | 363 | // `Schema` is a representation of OpenAPI v2 specification's Schema object. 364 | // 365 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject 366 | // 367 | message Schema { 368 | JSONSchema json_schema = 1; 369 | // Adds support for polymorphism. The discriminator is the schema property 370 | // name that is used to differentiate between other schema that inherit this 371 | // schema. The property name used MUST be defined at this schema and it MUST 372 | // be in the required property list. When used, the value MUST be the name of 373 | // this schema or any schema that inherits it. 374 | string discriminator = 2; 375 | // Relevant only for Schema "properties" definitions. Declares the property as 376 | // "read only". This means that it MAY be sent as part of a response but MUST 377 | // NOT be sent as part of the request. Properties marked as readOnly being 378 | // true SHOULD NOT be in the required list of the defined schema. Default 379 | // value is false. 380 | bool read_only = 3; 381 | // field 4 is reserved for 'xml'. 382 | reserved 4; 383 | // Additional external documentation for this schema. 384 | ExternalDocumentation external_docs = 5; 385 | // A free-form property to include an example of an instance for this schema in JSON. 386 | // This is copied verbatim to the output. 387 | string example = 6; 388 | } 389 | 390 | // `JSONSchema` represents properties from JSON Schema taken, and as used, in 391 | // the OpenAPI v2 spec. 392 | // 393 | // This includes changes made by OpenAPI v2. 394 | // 395 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject 396 | // 397 | // See also: https://cswr.github.io/JsonSchema/spec/basic_types/, 398 | // https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json 399 | // 400 | // Example: 401 | // 402 | // message SimpleMessage { 403 | // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { 404 | // json_schema: { 405 | // title: "SimpleMessage" 406 | // description: "A simple message." 407 | // required: ["id"] 408 | // } 409 | // }; 410 | // 411 | // // Id represents the message identifier. 412 | // string id = 1; [ 413 | // (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { 414 | // {description: "The unique identifier of the simple message." 415 | // }]; 416 | // } 417 | // 418 | message JSONSchema { 419 | // field 1 is reserved for '$id', omitted from OpenAPI v2. 420 | reserved 1; 421 | // field 2 is reserved for '$schema', omitted from OpenAPI v2. 422 | reserved 2; 423 | // Ref is used to define an external reference to include in the message. 424 | // This could be a fully qualified proto message reference, and that type must 425 | // be imported into the protofile. If no message is identified, the Ref will 426 | // be used verbatim in the output. 427 | // For example: 428 | // `ref: ".google.protobuf.Timestamp"`. 429 | string ref = 3; 430 | // field 4 is reserved for '$comment', omitted from OpenAPI v2. 431 | reserved 4; 432 | // The title of the schema. 433 | string title = 5; 434 | // A short description of the schema. 435 | string description = 6; 436 | string default = 7; 437 | bool read_only = 8; 438 | // A free-form property to include a JSON example of this field. This is copied 439 | // verbatim to the output swagger.json. Quotes must be escaped. 440 | // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject 441 | string example = 9; 442 | double multiple_of = 10; 443 | // Maximum represents an inclusive upper limit for a numeric instance. The 444 | // value of MUST be a number, 445 | double maximum = 11; 446 | bool exclusive_maximum = 12; 447 | // minimum represents an inclusive lower limit for a numeric instance. The 448 | // value of MUST be a number, 449 | double minimum = 13; 450 | bool exclusive_minimum = 14; 451 | uint64 max_length = 15; 452 | uint64 min_length = 16; 453 | string pattern = 17; 454 | // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2. 455 | reserved 18; 456 | // field 19 is reserved for 'items', but in OpenAPI-specific way. 457 | // TODO(ivucica): add 'items'? 458 | reserved 19; 459 | uint64 max_items = 20; 460 | uint64 min_items = 21; 461 | bool unique_items = 22; 462 | // field 23 is reserved for 'contains', omitted from OpenAPI v2. 463 | reserved 23; 464 | uint64 max_properties = 24; 465 | uint64 min_properties = 25; 466 | repeated string required = 26; 467 | // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific 468 | // way. TODO(ivucica): add 'additionalProperties'? 469 | reserved 27; 470 | // field 28 is reserved for 'definitions', omitted from OpenAPI v2. 471 | reserved 28; 472 | // field 29 is reserved for 'properties', but in OpenAPI-specific way. 473 | // TODO(ivucica): add 'additionalProperties'? 474 | reserved 29; 475 | // following fields are reserved, as the properties have been omitted from 476 | // OpenAPI v2: 477 | // patternProperties, dependencies, propertyNames, const 478 | reserved 30 to 33; 479 | // Items in 'array' must be unique. 480 | repeated string array = 34; 481 | 482 | enum JSONSchemaSimpleTypes { 483 | UNKNOWN = 0; 484 | ARRAY = 1; 485 | BOOLEAN = 2; 486 | INTEGER = 3; 487 | NULL = 4; 488 | NUMBER = 5; 489 | OBJECT = 6; 490 | STRING = 7; 491 | } 492 | 493 | repeated JSONSchemaSimpleTypes type = 35; 494 | // `Format` 495 | string format = 36; 496 | // following fields are reserved, as the properties have been omitted from 497 | // OpenAPI v2: contentMediaType, contentEncoding, if, then, else 498 | reserved 37 to 41; 499 | // field 42 is reserved for 'allOf', but in OpenAPI-specific way. 500 | // TODO(ivucica): add 'allOf'? 501 | reserved 42; 502 | // following fields are reserved, as the properties have been omitted from 503 | // OpenAPI v2: 504 | // anyOf, oneOf, not 505 | reserved 43 to 45; 506 | // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 507 | repeated string enum = 46; 508 | } 509 | 510 | // `Tag` is a representation of OpenAPI v2 specification's Tag object. 511 | // 512 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject 513 | // 514 | message Tag { 515 | // field 1 is reserved for 'name'. In our generator, this is (to be) extracted 516 | // from the name of proto service, and thus not exposed to the user, as 517 | // changing tag object's name would break the link to the references to the 518 | // tag in individual operation specifications. 519 | // 520 | // TODO(ivucica): Add 'name' property. Use it to allow override of the name of 521 | // global Tag object, then use that name to reference the tag throughout the 522 | // OpenAPI file. 523 | reserved 1; 524 | // A short description for the tag. GFM syntax can be used for rich text 525 | // representation. 526 | string description = 2; 527 | // Additional external documentation for this tag. 528 | ExternalDocumentation external_docs = 3; 529 | } 530 | 531 | // `SecurityDefinitions` is a representation of OpenAPI v2 specification's 532 | // Security Definitions object. 533 | // 534 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject 535 | // 536 | // A declaration of the security schemes available to be used in the 537 | // specification. This does not enforce the security schemes on the operations 538 | // and only serves to provide the relevant details for each scheme. 539 | message SecurityDefinitions { 540 | // A single security scheme definition, mapping a "name" to the scheme it 541 | // defines. 542 | map security = 1; 543 | } 544 | 545 | // `SecurityScheme` is a representation of OpenAPI v2 specification's 546 | // Security Scheme object. 547 | // 548 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject 549 | // 550 | // Allows the definition of a security scheme that can be used by the 551 | // operations. Supported schemes are basic authentication, an API key (either as 552 | // a header or as a query parameter) and OAuth2's common flows (implicit, 553 | // password, application and access code). 554 | message SecurityScheme { 555 | // The type of the security scheme. Valid values are "basic", 556 | // "apiKey" or "oauth2". 557 | enum Type { 558 | TYPE_INVALID = 0; 559 | TYPE_BASIC = 1; 560 | TYPE_API_KEY = 2; 561 | TYPE_OAUTH2 = 3; 562 | } 563 | 564 | // The location of the API key. Valid values are "query" or "header". 565 | enum In { 566 | IN_INVALID = 0; 567 | IN_QUERY = 1; 568 | IN_HEADER = 2; 569 | } 570 | 571 | // The flow used by the OAuth2 security scheme. Valid values are 572 | // "implicit", "password", "application" or "accessCode". 573 | enum Flow { 574 | FLOW_INVALID = 0; 575 | FLOW_IMPLICIT = 1; 576 | FLOW_PASSWORD = 2; 577 | FLOW_APPLICATION = 3; 578 | FLOW_ACCESS_CODE = 4; 579 | } 580 | 581 | // The type of the security scheme. Valid values are "basic", 582 | // "apiKey" or "oauth2". 583 | Type type = 1; 584 | // A short description for security scheme. 585 | string description = 2; 586 | // The name of the header or query parameter to be used. 587 | // Valid for apiKey. 588 | string name = 3; 589 | // The location of the API key. Valid values are "query" or 590 | // "header". 591 | // Valid for apiKey. 592 | In in = 4; 593 | // The flow used by the OAuth2 security scheme. Valid values are 594 | // "implicit", "password", "application" or "accessCode". 595 | // Valid for oauth2. 596 | Flow flow = 5; 597 | // The authorization URL to be used for this flow. This SHOULD be in 598 | // the form of a URL. 599 | // Valid for oauth2/implicit and oauth2/accessCode. 600 | string authorization_url = 6; 601 | // The token URL to be used for this flow. This SHOULD be in the 602 | // form of a URL. 603 | // Valid for oauth2/password, oauth2/application and oauth2/accessCode. 604 | string token_url = 7; 605 | // The available scopes for the OAuth2 security scheme. 606 | // Valid for oauth2. 607 | Scopes scopes = 8; 608 | map extensions = 9; 609 | } 610 | 611 | // `SecurityRequirement` is a representation of OpenAPI v2 specification's 612 | // Security Requirement object. 613 | // 614 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject 615 | // 616 | // Lists the required security schemes to execute this operation. The object can 617 | // have multiple security schemes declared in it which are all required (that 618 | // is, there is a logical AND between the schemes). 619 | // 620 | // The name used for each property MUST correspond to a security scheme 621 | // declared in the Security Definitions. 622 | message SecurityRequirement { 623 | // If the security scheme is of type "oauth2", then the value is a list of 624 | // scope names required for the execution. For other security scheme types, 625 | // the array MUST be empty. 626 | message SecurityRequirementValue { 627 | repeated string scope = 1; 628 | } 629 | // Each name must correspond to a security scheme which is declared in 630 | // the Security Definitions. If the security scheme is of type "oauth2", 631 | // then the value is a list of scope names required for the execution. 632 | // For other security scheme types, the array MUST be empty. 633 | map security_requirement = 1; 634 | } 635 | 636 | // `Scopes` is a representation of OpenAPI v2 specification's Scopes object. 637 | // 638 | // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject 639 | // 640 | // Lists the available scopes for an OAuth2 security scheme. 641 | message Scopes { 642 | // Maps between a name of a scope to a short description of it (as the value 643 | // of the property). 644 | map scope = 1; 645 | } -------------------------------------------------------------------------------- /api/v1/api.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v3.21.9 5 | // source: api/v1/api.proto 6 | 7 | package apiV1 8 | 9 | import ( 10 | _ "google.golang.org/genproto/googleapis/api/annotations" 11 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 12 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 13 | reflect "reflect" 14 | sync "sync" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type Empty struct { 25 | state protoimpl.MessageState 26 | sizeCache protoimpl.SizeCache 27 | unknownFields protoimpl.UnknownFields 28 | } 29 | 30 | func (x *Empty) Reset() { 31 | *x = Empty{} 32 | if protoimpl.UnsafeEnabled { 33 | mi := &file_api_v1_api_proto_msgTypes[0] 34 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 35 | ms.StoreMessageInfo(mi) 36 | } 37 | } 38 | 39 | func (x *Empty) String() string { 40 | return protoimpl.X.MessageStringOf(x) 41 | } 42 | 43 | func (*Empty) ProtoMessage() {} 44 | 45 | func (x *Empty) ProtoReflect() protoreflect.Message { 46 | mi := &file_api_v1_api_proto_msgTypes[0] 47 | if protoimpl.UnsafeEnabled && x != nil { 48 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 49 | if ms.LoadMessageInfo() == nil { 50 | ms.StoreMessageInfo(mi) 51 | } 52 | return ms 53 | } 54 | return mi.MessageOf(x) 55 | } 56 | 57 | // Deprecated: Use Empty.ProtoReflect.Descriptor instead. 58 | func (*Empty) Descriptor() ([]byte, []int) { 59 | return file_api_v1_api_proto_rawDescGZIP(), []int{0} 60 | } 61 | 62 | type User struct { 63 | state protoimpl.MessageState 64 | sizeCache protoimpl.SizeCache 65 | unknownFields protoimpl.UnknownFields 66 | 67 | Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` 68 | Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` 69 | Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` 70 | Email string `protobuf:"bytes,4,opt,name=email,proto3" json:"email,omitempty"` 71 | } 72 | 73 | func (x *User) Reset() { 74 | *x = User{} 75 | if protoimpl.UnsafeEnabled { 76 | mi := &file_api_v1_api_proto_msgTypes[1] 77 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 78 | ms.StoreMessageInfo(mi) 79 | } 80 | } 81 | 82 | func (x *User) String() string { 83 | return protoimpl.X.MessageStringOf(x) 84 | } 85 | 86 | func (*User) ProtoMessage() {} 87 | 88 | func (x *User) ProtoReflect() protoreflect.Message { 89 | mi := &file_api_v1_api_proto_msgTypes[1] 90 | if protoimpl.UnsafeEnabled && x != nil { 91 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 92 | if ms.LoadMessageInfo() == nil { 93 | ms.StoreMessageInfo(mi) 94 | } 95 | return ms 96 | } 97 | return mi.MessageOf(x) 98 | } 99 | 100 | // Deprecated: Use User.ProtoReflect.Descriptor instead. 101 | func (*User) Descriptor() ([]byte, []int) { 102 | return file_api_v1_api_proto_rawDescGZIP(), []int{1} 103 | } 104 | 105 | func (x *User) GetUid() int64 { 106 | if x != nil { 107 | return x.Uid 108 | } 109 | return 0 110 | } 111 | 112 | func (x *User) GetUsername() string { 113 | if x != nil { 114 | return x.Username 115 | } 116 | return "" 117 | } 118 | 119 | func (x *User) GetPassword() string { 120 | if x != nil { 121 | return x.Password 122 | } 123 | return "" 124 | } 125 | 126 | func (x *User) GetEmail() string { 127 | if x != nil { 128 | return x.Email 129 | } 130 | return "" 131 | } 132 | 133 | type CreateUserRequest struct { 134 | state protoimpl.MessageState 135 | sizeCache protoimpl.SizeCache 136 | unknownFields protoimpl.UnknownFields 137 | 138 | // 用户名 139 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 140 | // 用户密码 141 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 142 | // 用户邮箱 143 | Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` 144 | } 145 | 146 | func (x *CreateUserRequest) Reset() { 147 | *x = CreateUserRequest{} 148 | if protoimpl.UnsafeEnabled { 149 | mi := &file_api_v1_api_proto_msgTypes[2] 150 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 151 | ms.StoreMessageInfo(mi) 152 | } 153 | } 154 | 155 | func (x *CreateUserRequest) String() string { 156 | return protoimpl.X.MessageStringOf(x) 157 | } 158 | 159 | func (*CreateUserRequest) ProtoMessage() {} 160 | 161 | func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { 162 | mi := &file_api_v1_api_proto_msgTypes[2] 163 | if protoimpl.UnsafeEnabled && x != nil { 164 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 165 | if ms.LoadMessageInfo() == nil { 166 | ms.StoreMessageInfo(mi) 167 | } 168 | return ms 169 | } 170 | return mi.MessageOf(x) 171 | } 172 | 173 | // Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead. 174 | func (*CreateUserRequest) Descriptor() ([]byte, []int) { 175 | return file_api_v1_api_proto_rawDescGZIP(), []int{2} 176 | } 177 | 178 | func (x *CreateUserRequest) GetUsername() string { 179 | if x != nil { 180 | return x.Username 181 | } 182 | return "" 183 | } 184 | 185 | func (x *CreateUserRequest) GetPassword() string { 186 | if x != nil { 187 | return x.Password 188 | } 189 | return "" 190 | } 191 | 192 | func (x *CreateUserRequest) GetEmail() string { 193 | if x != nil { 194 | return x.Email 195 | } 196 | return "" 197 | } 198 | 199 | type CreateUserReply struct { 200 | state protoimpl.MessageState 201 | sizeCache protoimpl.SizeCache 202 | unknownFields protoimpl.UnknownFields 203 | 204 | // 用户ID 205 | Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` 206 | } 207 | 208 | func (x *CreateUserReply) Reset() { 209 | *x = CreateUserReply{} 210 | if protoimpl.UnsafeEnabled { 211 | mi := &file_api_v1_api_proto_msgTypes[3] 212 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 213 | ms.StoreMessageInfo(mi) 214 | } 215 | } 216 | 217 | func (x *CreateUserReply) String() string { 218 | return protoimpl.X.MessageStringOf(x) 219 | } 220 | 221 | func (*CreateUserReply) ProtoMessage() {} 222 | 223 | func (x *CreateUserReply) ProtoReflect() protoreflect.Message { 224 | mi := &file_api_v1_api_proto_msgTypes[3] 225 | if protoimpl.UnsafeEnabled && x != nil { 226 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 227 | if ms.LoadMessageInfo() == nil { 228 | ms.StoreMessageInfo(mi) 229 | } 230 | return ms 231 | } 232 | return mi.MessageOf(x) 233 | } 234 | 235 | // Deprecated: Use CreateUserReply.ProtoReflect.Descriptor instead. 236 | func (*CreateUserReply) Descriptor() ([]byte, []int) { 237 | return file_api_v1_api_proto_rawDescGZIP(), []int{3} 238 | } 239 | 240 | func (x *CreateUserReply) GetUid() int64 { 241 | if x != nil { 242 | return x.Uid 243 | } 244 | return 0 245 | } 246 | 247 | type UpdateUserRequest struct { 248 | state protoimpl.MessageState 249 | sizeCache protoimpl.SizeCache 250 | unknownFields protoimpl.UnknownFields 251 | 252 | // 用户ID 253 | Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` 254 | // 用户密码 255 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 256 | // 用户邮箱 257 | Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` 258 | } 259 | 260 | func (x *UpdateUserRequest) Reset() { 261 | *x = UpdateUserRequest{} 262 | if protoimpl.UnsafeEnabled { 263 | mi := &file_api_v1_api_proto_msgTypes[4] 264 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 265 | ms.StoreMessageInfo(mi) 266 | } 267 | } 268 | 269 | func (x *UpdateUserRequest) String() string { 270 | return protoimpl.X.MessageStringOf(x) 271 | } 272 | 273 | func (*UpdateUserRequest) ProtoMessage() {} 274 | 275 | func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { 276 | mi := &file_api_v1_api_proto_msgTypes[4] 277 | if protoimpl.UnsafeEnabled && x != nil { 278 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 279 | if ms.LoadMessageInfo() == nil { 280 | ms.StoreMessageInfo(mi) 281 | } 282 | return ms 283 | } 284 | return mi.MessageOf(x) 285 | } 286 | 287 | // Deprecated: Use UpdateUserRequest.ProtoReflect.Descriptor instead. 288 | func (*UpdateUserRequest) Descriptor() ([]byte, []int) { 289 | return file_api_v1_api_proto_rawDescGZIP(), []int{4} 290 | } 291 | 292 | func (x *UpdateUserRequest) GetUid() int64 { 293 | if x != nil { 294 | return x.Uid 295 | } 296 | return 0 297 | } 298 | 299 | func (x *UpdateUserRequest) GetPassword() string { 300 | if x != nil { 301 | return x.Password 302 | } 303 | return "" 304 | } 305 | 306 | func (x *UpdateUserRequest) GetEmail() string { 307 | if x != nil { 308 | return x.Email 309 | } 310 | return "" 311 | } 312 | 313 | type GetUserRequest struct { 314 | state protoimpl.MessageState 315 | sizeCache protoimpl.SizeCache 316 | unknownFields protoimpl.UnknownFields 317 | 318 | // 用户ID 319 | Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` 320 | } 321 | 322 | func (x *GetUserRequest) Reset() { 323 | *x = GetUserRequest{} 324 | if protoimpl.UnsafeEnabled { 325 | mi := &file_api_v1_api_proto_msgTypes[5] 326 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 327 | ms.StoreMessageInfo(mi) 328 | } 329 | } 330 | 331 | func (x *GetUserRequest) String() string { 332 | return protoimpl.X.MessageStringOf(x) 333 | } 334 | 335 | func (*GetUserRequest) ProtoMessage() {} 336 | 337 | func (x *GetUserRequest) ProtoReflect() protoreflect.Message { 338 | mi := &file_api_v1_api_proto_msgTypes[5] 339 | if protoimpl.UnsafeEnabled && x != nil { 340 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 341 | if ms.LoadMessageInfo() == nil { 342 | ms.StoreMessageInfo(mi) 343 | } 344 | return ms 345 | } 346 | return mi.MessageOf(x) 347 | } 348 | 349 | // Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead. 350 | func (*GetUserRequest) Descriptor() ([]byte, []int) { 351 | return file_api_v1_api_proto_rawDescGZIP(), []int{5} 352 | } 353 | 354 | func (x *GetUserRequest) GetUid() int64 { 355 | if x != nil { 356 | return x.Uid 357 | } 358 | return 0 359 | } 360 | 361 | type DeleteUserRequest struct { 362 | state protoimpl.MessageState 363 | sizeCache protoimpl.SizeCache 364 | unknownFields protoimpl.UnknownFields 365 | 366 | // 用户ID 367 | Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` 368 | } 369 | 370 | func (x *DeleteUserRequest) Reset() { 371 | *x = DeleteUserRequest{} 372 | if protoimpl.UnsafeEnabled { 373 | mi := &file_api_v1_api_proto_msgTypes[6] 374 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 375 | ms.StoreMessageInfo(mi) 376 | } 377 | } 378 | 379 | func (x *DeleteUserRequest) String() string { 380 | return protoimpl.X.MessageStringOf(x) 381 | } 382 | 383 | func (*DeleteUserRequest) ProtoMessage() {} 384 | 385 | func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { 386 | mi := &file_api_v1_api_proto_msgTypes[6] 387 | if protoimpl.UnsafeEnabled && x != nil { 388 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 389 | if ms.LoadMessageInfo() == nil { 390 | ms.StoreMessageInfo(mi) 391 | } 392 | return ms 393 | } 394 | return mi.MessageOf(x) 395 | } 396 | 397 | // Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead. 398 | func (*DeleteUserRequest) Descriptor() ([]byte, []int) { 399 | return file_api_v1_api_proto_rawDescGZIP(), []int{6} 400 | } 401 | 402 | func (x *DeleteUserRequest) GetUid() int64 { 403 | if x != nil { 404 | return x.Uid 405 | } 406 | return 0 407 | } 408 | 409 | type ListUserRequest struct { 410 | state protoimpl.MessageState 411 | sizeCache protoimpl.SizeCache 412 | unknownFields protoimpl.UnknownFields 413 | 414 | // 偏移量 415 | Offset int64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"` 416 | // 每页数量 417 | Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` 418 | } 419 | 420 | func (x *ListUserRequest) Reset() { 421 | *x = ListUserRequest{} 422 | if protoimpl.UnsafeEnabled { 423 | mi := &file_api_v1_api_proto_msgTypes[7] 424 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 425 | ms.StoreMessageInfo(mi) 426 | } 427 | } 428 | 429 | func (x *ListUserRequest) String() string { 430 | return protoimpl.X.MessageStringOf(x) 431 | } 432 | 433 | func (*ListUserRequest) ProtoMessage() {} 434 | 435 | func (x *ListUserRequest) ProtoReflect() protoreflect.Message { 436 | mi := &file_api_v1_api_proto_msgTypes[7] 437 | if protoimpl.UnsafeEnabled && x != nil { 438 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 439 | if ms.LoadMessageInfo() == nil { 440 | ms.StoreMessageInfo(mi) 441 | } 442 | return ms 443 | } 444 | return mi.MessageOf(x) 445 | } 446 | 447 | // Deprecated: Use ListUserRequest.ProtoReflect.Descriptor instead. 448 | func (*ListUserRequest) Descriptor() ([]byte, []int) { 449 | return file_api_v1_api_proto_rawDescGZIP(), []int{7} 450 | } 451 | 452 | func (x *ListUserRequest) GetOffset() int64 { 453 | if x != nil { 454 | return x.Offset 455 | } 456 | return 0 457 | } 458 | 459 | func (x *ListUserRequest) GetLimit() int64 { 460 | if x != nil { 461 | return x.Limit 462 | } 463 | return 0 464 | } 465 | 466 | type ListUserReply struct { 467 | state protoimpl.MessageState 468 | sizeCache protoimpl.SizeCache 469 | unknownFields protoimpl.UnknownFields 470 | 471 | // 总数 472 | Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` 473 | // 用户列表 474 | Items []*User `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"` 475 | } 476 | 477 | func (x *ListUserReply) Reset() { 478 | *x = ListUserReply{} 479 | if protoimpl.UnsafeEnabled { 480 | mi := &file_api_v1_api_proto_msgTypes[8] 481 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 482 | ms.StoreMessageInfo(mi) 483 | } 484 | } 485 | 486 | func (x *ListUserReply) String() string { 487 | return protoimpl.X.MessageStringOf(x) 488 | } 489 | 490 | func (*ListUserReply) ProtoMessage() {} 491 | 492 | func (x *ListUserReply) ProtoReflect() protoreflect.Message { 493 | mi := &file_api_v1_api_proto_msgTypes[8] 494 | if protoimpl.UnsafeEnabled && x != nil { 495 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 496 | if ms.LoadMessageInfo() == nil { 497 | ms.StoreMessageInfo(mi) 498 | } 499 | return ms 500 | } 501 | return mi.MessageOf(x) 502 | } 503 | 504 | // Deprecated: Use ListUserReply.ProtoReflect.Descriptor instead. 505 | func (*ListUserReply) Descriptor() ([]byte, []int) { 506 | return file_api_v1_api_proto_rawDescGZIP(), []int{8} 507 | } 508 | 509 | func (x *ListUserReply) GetTotal() int64 { 510 | if x != nil { 511 | return x.Total 512 | } 513 | return 0 514 | } 515 | 516 | func (x *ListUserReply) GetItems() []*User { 517 | if x != nil { 518 | return x.Items 519 | } 520 | return nil 521 | } 522 | 523 | var File_api_v1_api_proto protoreflect.FileDescriptor 524 | 525 | var file_api_v1_api_proto_rawDesc = []byte{ 526 | 0x0a, 0x10, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 527 | 0x74, 0x6f, 0x12, 0x07, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 528 | 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 529 | 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 530 | 0x74, 0x79, 0x22, 0x66, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 531 | 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 532 | 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 533 | 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 534 | 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 535 | 0x77, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 536 | 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x61, 0x0a, 0x11, 0x43, 0x72, 537 | 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 538 | 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 539 | 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 540 | 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 541 | 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 542 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x23, 0x0a, 543 | 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 544 | 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 545 | 0x69, 0x64, 0x22, 0x57, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 546 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 547 | 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 548 | 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 549 | 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 550 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x22, 0x0a, 0x0e, 0x47, 551 | 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 552 | 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 553 | 0x25, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 554 | 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 555 | 0x03, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0x3f, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 556 | 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 557 | 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 558 | 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 559 | 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x4a, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x55, 560 | 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 561 | 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x23, 562 | 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 563 | 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x69, 0x74, 564 | 0x65, 0x6d, 0x73, 0x32, 0x94, 0x03, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 565 | 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x17, 566 | 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 567 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 568 | 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x12, 0x0c, 569 | 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x4b, 0x0a, 0x0a, 570 | 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 571 | 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 572 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 573 | 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x06, 574 | 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x51, 0x0a, 0x0a, 0x55, 0x70, 0x64, 575 | 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 576 | 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 577 | 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 578 | 0x70, 0x74, 0x79, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x1a, 0x0c, 0x2f, 0x75, 0x73, 579 | 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x3a, 0x01, 0x2a, 0x12, 0x4e, 0x0a, 0x0a, 580 | 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 581 | 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 582 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 583 | 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x2a, 0x0c, 584 | 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x4c, 0x0a, 0x08, 585 | 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 586 | 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 587 | 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 588 | 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x0e, 0x82, 0xd3, 0xe4, 0x93, 589 | 0x02, 0x08, 0x12, 0x06, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 590 | 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x79, 0x6f, 0x75, 0x74, 0x68, 0x7a, 591 | 0x7a, 0x7a, 0x2f, 0x67, 0x6f, 0x2d, 0x77, 0x65, 0x62, 0x2d, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 592 | 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x56, 0x31, 0x62, 0x06, 0x70, 593 | 0x72, 0x6f, 0x74, 0x6f, 0x33, 594 | } 595 | 596 | var ( 597 | file_api_v1_api_proto_rawDescOnce sync.Once 598 | file_api_v1_api_proto_rawDescData = file_api_v1_api_proto_rawDesc 599 | ) 600 | 601 | func file_api_v1_api_proto_rawDescGZIP() []byte { 602 | file_api_v1_api_proto_rawDescOnce.Do(func() { 603 | file_api_v1_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_v1_api_proto_rawDescData) 604 | }) 605 | return file_api_v1_api_proto_rawDescData 606 | } 607 | 608 | var file_api_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 9) 609 | var file_api_v1_api_proto_goTypes = []interface{}{ 610 | (*Empty)(nil), // 0: user.v1.Empty 611 | (*User)(nil), // 1: user.v1.User 612 | (*CreateUserRequest)(nil), // 2: user.v1.CreateUserRequest 613 | (*CreateUserReply)(nil), // 3: user.v1.CreateUserReply 614 | (*UpdateUserRequest)(nil), // 4: user.v1.UpdateUserRequest 615 | (*GetUserRequest)(nil), // 5: user.v1.GetUserRequest 616 | (*DeleteUserRequest)(nil), // 6: user.v1.DeleteUserRequest 617 | (*ListUserRequest)(nil), // 7: user.v1.ListUserRequest 618 | (*ListUserReply)(nil), // 8: user.v1.ListUserReply 619 | } 620 | var file_api_v1_api_proto_depIdxs = []int32{ 621 | 1, // 0: user.v1.ListUserReply.items:type_name -> user.v1.User 622 | 5, // 1: user.v1.UserService.GetUser:input_type -> user.v1.GetUserRequest 623 | 2, // 2: user.v1.UserService.CreateUser:input_type -> user.v1.CreateUserRequest 624 | 4, // 3: user.v1.UserService.UpdateUser:input_type -> user.v1.UpdateUserRequest 625 | 6, // 4: user.v1.UserService.DeleteUser:input_type -> user.v1.DeleteUserRequest 626 | 7, // 5: user.v1.UserService.ListUser:input_type -> user.v1.ListUserRequest 627 | 1, // 6: user.v1.UserService.GetUser:output_type -> user.v1.User 628 | 0, // 7: user.v1.UserService.CreateUser:output_type -> user.v1.Empty 629 | 0, // 8: user.v1.UserService.UpdateUser:output_type -> user.v1.Empty 630 | 0, // 9: user.v1.UserService.DeleteUser:output_type -> user.v1.Empty 631 | 8, // 10: user.v1.UserService.ListUser:output_type -> user.v1.ListUserReply 632 | 6, // [6:11] is the sub-list for method output_type 633 | 1, // [1:6] is the sub-list for method input_type 634 | 1, // [1:1] is the sub-list for extension type_name 635 | 1, // [1:1] is the sub-list for extension extendee 636 | 0, // [0:1] is the sub-list for field type_name 637 | } 638 | 639 | func init() { file_api_v1_api_proto_init() } 640 | func file_api_v1_api_proto_init() { 641 | if File_api_v1_api_proto != nil { 642 | return 643 | } 644 | if !protoimpl.UnsafeEnabled { 645 | file_api_v1_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 646 | switch v := v.(*Empty); i { 647 | case 0: 648 | return &v.state 649 | case 1: 650 | return &v.sizeCache 651 | case 2: 652 | return &v.unknownFields 653 | default: 654 | return nil 655 | } 656 | } 657 | file_api_v1_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 658 | switch v := v.(*User); i { 659 | case 0: 660 | return &v.state 661 | case 1: 662 | return &v.sizeCache 663 | case 2: 664 | return &v.unknownFields 665 | default: 666 | return nil 667 | } 668 | } 669 | file_api_v1_api_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 670 | switch v := v.(*CreateUserRequest); i { 671 | case 0: 672 | return &v.state 673 | case 1: 674 | return &v.sizeCache 675 | case 2: 676 | return &v.unknownFields 677 | default: 678 | return nil 679 | } 680 | } 681 | file_api_v1_api_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 682 | switch v := v.(*CreateUserReply); i { 683 | case 0: 684 | return &v.state 685 | case 1: 686 | return &v.sizeCache 687 | case 2: 688 | return &v.unknownFields 689 | default: 690 | return nil 691 | } 692 | } 693 | file_api_v1_api_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 694 | switch v := v.(*UpdateUserRequest); i { 695 | case 0: 696 | return &v.state 697 | case 1: 698 | return &v.sizeCache 699 | case 2: 700 | return &v.unknownFields 701 | default: 702 | return nil 703 | } 704 | } 705 | file_api_v1_api_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 706 | switch v := v.(*GetUserRequest); i { 707 | case 0: 708 | return &v.state 709 | case 1: 710 | return &v.sizeCache 711 | case 2: 712 | return &v.unknownFields 713 | default: 714 | return nil 715 | } 716 | } 717 | file_api_v1_api_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 718 | switch v := v.(*DeleteUserRequest); i { 719 | case 0: 720 | return &v.state 721 | case 1: 722 | return &v.sizeCache 723 | case 2: 724 | return &v.unknownFields 725 | default: 726 | return nil 727 | } 728 | } 729 | file_api_v1_api_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { 730 | switch v := v.(*ListUserRequest); i { 731 | case 0: 732 | return &v.state 733 | case 1: 734 | return &v.sizeCache 735 | case 2: 736 | return &v.unknownFields 737 | default: 738 | return nil 739 | } 740 | } 741 | file_api_v1_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { 742 | switch v := v.(*ListUserReply); i { 743 | case 0: 744 | return &v.state 745 | case 1: 746 | return &v.sizeCache 747 | case 2: 748 | return &v.unknownFields 749 | default: 750 | return nil 751 | } 752 | } 753 | } 754 | type x struct{} 755 | out := protoimpl.TypeBuilder{ 756 | File: protoimpl.DescBuilder{ 757 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 758 | RawDescriptor: file_api_v1_api_proto_rawDesc, 759 | NumEnums: 0, 760 | NumMessages: 9, 761 | NumExtensions: 0, 762 | NumServices: 1, 763 | }, 764 | GoTypes: file_api_v1_api_proto_goTypes, 765 | DependencyIndexes: file_api_v1_api_proto_depIdxs, 766 | MessageInfos: file_api_v1_api_proto_msgTypes, 767 | }.Build() 768 | File_api_v1_api_proto = out.File 769 | file_api_v1_api_proto_rawDesc = nil 770 | file_api_v1_api_proto_goTypes = nil 771 | file_api_v1_api_proto_depIdxs = nil 772 | } 773 | -------------------------------------------------------------------------------- /third_party/validate/validate.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package validate; 3 | 4 | option go_package = "github.com/envoyproxy/protoc-gen-validate/validate"; 5 | option java_package = "io.envoyproxy.pgv.validate"; 6 | 7 | import "google/protobuf/descriptor.proto"; 8 | import "google/protobuf/duration.proto"; 9 | import "google/protobuf/timestamp.proto"; 10 | 11 | // Validation rules applied at the message level 12 | extend google.protobuf.MessageOptions { 13 | // Disabled nullifies any validation rules for this message, including any 14 | // message fields associated with it that do support validation. 15 | optional bool disabled = 1071; 16 | // Ignore skips generation of validation methods for this message. 17 | optional bool ignored = 1072; 18 | } 19 | 20 | // Validation rules applied at the oneof level 21 | extend google.protobuf.OneofOptions { 22 | // Required ensures that exactly one the field options in a oneof is set; 23 | // validation fails if no fields in the oneof are set. 24 | optional bool required = 1071; 25 | } 26 | 27 | // Validation rules applied at the field level 28 | extend google.protobuf.FieldOptions { 29 | // Rules specify the validations to be performed on this field. By default, 30 | // no validation is performed against a field. 31 | optional FieldRules rules = 1071; 32 | } 33 | 34 | // FieldRules encapsulates the rules for each type of field. Depending on the 35 | // field, the correct set should be used to ensure proper validations. 36 | message FieldRules { 37 | optional MessageRules message = 17; 38 | oneof type { 39 | // Scalar Field Types 40 | FloatRules float = 1; 41 | DoubleRules double = 2; 42 | Int32Rules int32 = 3; 43 | Int64Rules int64 = 4; 44 | UInt32Rules uint32 = 5; 45 | UInt64Rules uint64 = 6; 46 | SInt32Rules sint32 = 7; 47 | SInt64Rules sint64 = 8; 48 | Fixed32Rules fixed32 = 9; 49 | Fixed64Rules fixed64 = 10; 50 | SFixed32Rules sfixed32 = 11; 51 | SFixed64Rules sfixed64 = 12; 52 | BoolRules bool = 13; 53 | StringRules string = 14; 54 | BytesRules bytes = 15; 55 | 56 | // Complex Field Types 57 | EnumRules enum = 16; 58 | RepeatedRules repeated = 18; 59 | MapRules map = 19; 60 | 61 | // Well-Known Field Types 62 | AnyRules any = 20; 63 | DurationRules duration = 21; 64 | TimestampRules timestamp = 22; 65 | } 66 | } 67 | 68 | // FloatRules describes the constraints applied to `float` values 69 | message FloatRules { 70 | // Const specifies that this field must be exactly the specified value 71 | optional float const = 1; 72 | 73 | // Lt specifies that this field must be less than the specified value, 74 | // exclusive 75 | optional float lt = 2; 76 | 77 | // Lte specifies that this field must be less than or equal to the 78 | // specified value, inclusive 79 | optional float lte = 3; 80 | 81 | // Gt specifies that this field must be greater than the specified value, 82 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 83 | // range is reversed. 84 | optional float gt = 4; 85 | 86 | // Gte specifies that this field must be greater than or equal to the 87 | // specified value, inclusive. If the value of Gte is larger than a 88 | // specified Lt or Lte, the range is reversed. 89 | optional float gte = 5; 90 | 91 | // In specifies that this field must be equal to one of the specified 92 | // values 93 | repeated float in = 6; 94 | 95 | // NotIn specifies that this field cannot be equal to one of the specified 96 | // values 97 | repeated float not_in = 7; 98 | 99 | // IgnoreEmpty specifies that the validation rules of this field should be 100 | // evaluated only if the field is not empty 101 | optional bool ignore_empty = 8; 102 | } 103 | 104 | // DoubleRules describes the constraints applied to `double` values 105 | message DoubleRules { 106 | // Const specifies that this field must be exactly the specified value 107 | optional double const = 1; 108 | 109 | // Lt specifies that this field must be less than the specified value, 110 | // exclusive 111 | optional double lt = 2; 112 | 113 | // Lte specifies that this field must be less than or equal to the 114 | // specified value, inclusive 115 | optional double lte = 3; 116 | 117 | // Gt specifies that this field must be greater than the specified value, 118 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 119 | // range is reversed. 120 | optional double gt = 4; 121 | 122 | // Gte specifies that this field must be greater than or equal to the 123 | // specified value, inclusive. If the value of Gte is larger than a 124 | // specified Lt or Lte, the range is reversed. 125 | optional double gte = 5; 126 | 127 | // In specifies that this field must be equal to one of the specified 128 | // values 129 | repeated double in = 6; 130 | 131 | // NotIn specifies that this field cannot be equal to one of the specified 132 | // values 133 | repeated double not_in = 7; 134 | 135 | // IgnoreEmpty specifies that the validation rules of this field should be 136 | // evaluated only if the field is not empty 137 | optional bool ignore_empty = 8; 138 | } 139 | 140 | // Int32Rules describes the constraints applied to `int32` values 141 | message Int32Rules { 142 | // Const specifies that this field must be exactly the specified value 143 | optional int32 const = 1; 144 | 145 | // Lt specifies that this field must be less than the specified value, 146 | // exclusive 147 | optional int32 lt = 2; 148 | 149 | // Lte specifies that this field must be less than or equal to the 150 | // specified value, inclusive 151 | optional int32 lte = 3; 152 | 153 | // Gt specifies that this field must be greater than the specified value, 154 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 155 | // range is reversed. 156 | optional int32 gt = 4; 157 | 158 | // Gte specifies that this field must be greater than or equal to the 159 | // specified value, inclusive. If the value of Gte is larger than a 160 | // specified Lt or Lte, the range is reversed. 161 | optional int32 gte = 5; 162 | 163 | // In specifies that this field must be equal to one of the specified 164 | // values 165 | repeated int32 in = 6; 166 | 167 | // NotIn specifies that this field cannot be equal to one of the specified 168 | // values 169 | repeated int32 not_in = 7; 170 | 171 | // IgnoreEmpty specifies that the validation rules of this field should be 172 | // evaluated only if the field is not empty 173 | optional bool ignore_empty = 8; 174 | } 175 | 176 | // Int64Rules describes the constraints applied to `int64` values 177 | message Int64Rules { 178 | // Const specifies that this field must be exactly the specified value 179 | optional int64 const = 1; 180 | 181 | // Lt specifies that this field must be less than the specified value, 182 | // exclusive 183 | optional int64 lt = 2; 184 | 185 | // Lte specifies that this field must be less than or equal to the 186 | // specified value, inclusive 187 | optional int64 lte = 3; 188 | 189 | // Gt specifies that this field must be greater than the specified value, 190 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 191 | // range is reversed. 192 | optional int64 gt = 4; 193 | 194 | // Gte specifies that this field must be greater than or equal to the 195 | // specified value, inclusive. If the value of Gte is larger than a 196 | // specified Lt or Lte, the range is reversed. 197 | optional int64 gte = 5; 198 | 199 | // In specifies that this field must be equal to one of the specified 200 | // values 201 | repeated int64 in = 6; 202 | 203 | // NotIn specifies that this field cannot be equal to one of the specified 204 | // values 205 | repeated int64 not_in = 7; 206 | 207 | // IgnoreEmpty specifies that the validation rules of this field should be 208 | // evaluated only if the field is not empty 209 | optional bool ignore_empty = 8; 210 | } 211 | 212 | // UInt32Rules describes the constraints applied to `uint32` values 213 | message UInt32Rules { 214 | // Const specifies that this field must be exactly the specified value 215 | optional uint32 const = 1; 216 | 217 | // Lt specifies that this field must be less than the specified value, 218 | // exclusive 219 | optional uint32 lt = 2; 220 | 221 | // Lte specifies that this field must be less than or equal to the 222 | // specified value, inclusive 223 | optional uint32 lte = 3; 224 | 225 | // Gt specifies that this field must be greater than the specified value, 226 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 227 | // range is reversed. 228 | optional uint32 gt = 4; 229 | 230 | // Gte specifies that this field must be greater than or equal to the 231 | // specified value, inclusive. If the value of Gte is larger than a 232 | // specified Lt or Lte, the range is reversed. 233 | optional uint32 gte = 5; 234 | 235 | // In specifies that this field must be equal to one of the specified 236 | // values 237 | repeated uint32 in = 6; 238 | 239 | // NotIn specifies that this field cannot be equal to one of the specified 240 | // values 241 | repeated uint32 not_in = 7; 242 | 243 | // IgnoreEmpty specifies that the validation rules of this field should be 244 | // evaluated only if the field is not empty 245 | optional bool ignore_empty = 8; 246 | } 247 | 248 | // UInt64Rules describes the constraints applied to `uint64` values 249 | message UInt64Rules { 250 | // Const specifies that this field must be exactly the specified value 251 | optional uint64 const = 1; 252 | 253 | // Lt specifies that this field must be less than the specified value, 254 | // exclusive 255 | optional uint64 lt = 2; 256 | 257 | // Lte specifies that this field must be less than or equal to the 258 | // specified value, inclusive 259 | optional uint64 lte = 3; 260 | 261 | // Gt specifies that this field must be greater than the specified value, 262 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 263 | // range is reversed. 264 | optional uint64 gt = 4; 265 | 266 | // Gte specifies that this field must be greater than or equal to the 267 | // specified value, inclusive. If the value of Gte is larger than a 268 | // specified Lt or Lte, the range is reversed. 269 | optional uint64 gte = 5; 270 | 271 | // In specifies that this field must be equal to one of the specified 272 | // values 273 | repeated uint64 in = 6; 274 | 275 | // NotIn specifies that this field cannot be equal to one of the specified 276 | // values 277 | repeated uint64 not_in = 7; 278 | 279 | // IgnoreEmpty specifies that the validation rules of this field should be 280 | // evaluated only if the field is not empty 281 | optional bool ignore_empty = 8; 282 | } 283 | 284 | // SInt32Rules describes the constraints applied to `sint32` values 285 | message SInt32Rules { 286 | // Const specifies that this field must be exactly the specified value 287 | optional sint32 const = 1; 288 | 289 | // Lt specifies that this field must be less than the specified value, 290 | // exclusive 291 | optional sint32 lt = 2; 292 | 293 | // Lte specifies that this field must be less than or equal to the 294 | // specified value, inclusive 295 | optional sint32 lte = 3; 296 | 297 | // Gt specifies that this field must be greater than the specified value, 298 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 299 | // range is reversed. 300 | optional sint32 gt = 4; 301 | 302 | // Gte specifies that this field must be greater than or equal to the 303 | // specified value, inclusive. If the value of Gte is larger than a 304 | // specified Lt or Lte, the range is reversed. 305 | optional sint32 gte = 5; 306 | 307 | // In specifies that this field must be equal to one of the specified 308 | // values 309 | repeated sint32 in = 6; 310 | 311 | // NotIn specifies that this field cannot be equal to one of the specified 312 | // values 313 | repeated sint32 not_in = 7; 314 | 315 | // IgnoreEmpty specifies that the validation rules of this field should be 316 | // evaluated only if the field is not empty 317 | optional bool ignore_empty = 8; 318 | } 319 | 320 | // SInt64Rules describes the constraints applied to `sint64` values 321 | message SInt64Rules { 322 | // Const specifies that this field must be exactly the specified value 323 | optional sint64 const = 1; 324 | 325 | // Lt specifies that this field must be less than the specified value, 326 | // exclusive 327 | optional sint64 lt = 2; 328 | 329 | // Lte specifies that this field must be less than or equal to the 330 | // specified value, inclusive 331 | optional sint64 lte = 3; 332 | 333 | // Gt specifies that this field must be greater than the specified value, 334 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 335 | // range is reversed. 336 | optional sint64 gt = 4; 337 | 338 | // Gte specifies that this field must be greater than or equal to the 339 | // specified value, inclusive. If the value of Gte is larger than a 340 | // specified Lt or Lte, the range is reversed. 341 | optional sint64 gte = 5; 342 | 343 | // In specifies that this field must be equal to one of the specified 344 | // values 345 | repeated sint64 in = 6; 346 | 347 | // NotIn specifies that this field cannot be equal to one of the specified 348 | // values 349 | repeated sint64 not_in = 7; 350 | 351 | // IgnoreEmpty specifies that the validation rules of this field should be 352 | // evaluated only if the field is not empty 353 | optional bool ignore_empty = 8; 354 | } 355 | 356 | // Fixed32Rules describes the constraints applied to `fixed32` values 357 | message Fixed32Rules { 358 | // Const specifies that this field must be exactly the specified value 359 | optional fixed32 const = 1; 360 | 361 | // Lt specifies that this field must be less than the specified value, 362 | // exclusive 363 | optional fixed32 lt = 2; 364 | 365 | // Lte specifies that this field must be less than or equal to the 366 | // specified value, inclusive 367 | optional fixed32 lte = 3; 368 | 369 | // Gt specifies that this field must be greater than the specified value, 370 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 371 | // range is reversed. 372 | optional fixed32 gt = 4; 373 | 374 | // Gte specifies that this field must be greater than or equal to the 375 | // specified value, inclusive. If the value of Gte is larger than a 376 | // specified Lt or Lte, the range is reversed. 377 | optional fixed32 gte = 5; 378 | 379 | // In specifies that this field must be equal to one of the specified 380 | // values 381 | repeated fixed32 in = 6; 382 | 383 | // NotIn specifies that this field cannot be equal to one of the specified 384 | // values 385 | repeated fixed32 not_in = 7; 386 | 387 | // IgnoreEmpty specifies that the validation rules of this field should be 388 | // evaluated only if the field is not empty 389 | optional bool ignore_empty = 8; 390 | } 391 | 392 | // Fixed64Rules describes the constraints applied to `fixed64` values 393 | message Fixed64Rules { 394 | // Const specifies that this field must be exactly the specified value 395 | optional fixed64 const = 1; 396 | 397 | // Lt specifies that this field must be less than the specified value, 398 | // exclusive 399 | optional fixed64 lt = 2; 400 | 401 | // Lte specifies that this field must be less than or equal to the 402 | // specified value, inclusive 403 | optional fixed64 lte = 3; 404 | 405 | // Gt specifies that this field must be greater than the specified value, 406 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 407 | // range is reversed. 408 | optional fixed64 gt = 4; 409 | 410 | // Gte specifies that this field must be greater than or equal to the 411 | // specified value, inclusive. If the value of Gte is larger than a 412 | // specified Lt or Lte, the range is reversed. 413 | optional fixed64 gte = 5; 414 | 415 | // In specifies that this field must be equal to one of the specified 416 | // values 417 | repeated fixed64 in = 6; 418 | 419 | // NotIn specifies that this field cannot be equal to one of the specified 420 | // values 421 | repeated fixed64 not_in = 7; 422 | 423 | // IgnoreEmpty specifies that the validation rules of this field should be 424 | // evaluated only if the field is not empty 425 | optional bool ignore_empty = 8; 426 | } 427 | 428 | // SFixed32Rules describes the constraints applied to `sfixed32` values 429 | message SFixed32Rules { 430 | // Const specifies that this field must be exactly the specified value 431 | optional sfixed32 const = 1; 432 | 433 | // Lt specifies that this field must be less than the specified value, 434 | // exclusive 435 | optional sfixed32 lt = 2; 436 | 437 | // Lte specifies that this field must be less than or equal to the 438 | // specified value, inclusive 439 | optional sfixed32 lte = 3; 440 | 441 | // Gt specifies that this field must be greater than the specified value, 442 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 443 | // range is reversed. 444 | optional sfixed32 gt = 4; 445 | 446 | // Gte specifies that this field must be greater than or equal to the 447 | // specified value, inclusive. If the value of Gte is larger than a 448 | // specified Lt or Lte, the range is reversed. 449 | optional sfixed32 gte = 5; 450 | 451 | // In specifies that this field must be equal to one of the specified 452 | // values 453 | repeated sfixed32 in = 6; 454 | 455 | // NotIn specifies that this field cannot be equal to one of the specified 456 | // values 457 | repeated sfixed32 not_in = 7; 458 | 459 | // IgnoreEmpty specifies that the validation rules of this field should be 460 | // evaluated only if the field is not empty 461 | optional bool ignore_empty = 8; 462 | } 463 | 464 | // SFixed64Rules describes the constraints applied to `sfixed64` values 465 | message SFixed64Rules { 466 | // Const specifies that this field must be exactly the specified value 467 | optional sfixed64 const = 1; 468 | 469 | // Lt specifies that this field must be less than the specified value, 470 | // exclusive 471 | optional sfixed64 lt = 2; 472 | 473 | // Lte specifies that this field must be less than or equal to the 474 | // specified value, inclusive 475 | optional sfixed64 lte = 3; 476 | 477 | // Gt specifies that this field must be greater than the specified value, 478 | // exclusive. If the value of Gt is larger than a specified Lt or Lte, the 479 | // range is reversed. 480 | optional sfixed64 gt = 4; 481 | 482 | // Gte specifies that this field must be greater than or equal to the 483 | // specified value, inclusive. If the value of Gte is larger than a 484 | // specified Lt or Lte, the range is reversed. 485 | optional sfixed64 gte = 5; 486 | 487 | // In specifies that this field must be equal to one of the specified 488 | // values 489 | repeated sfixed64 in = 6; 490 | 491 | // NotIn specifies that this field cannot be equal to one of the specified 492 | // values 493 | repeated sfixed64 not_in = 7; 494 | 495 | // IgnoreEmpty specifies that the validation rules of this field should be 496 | // evaluated only if the field is not empty 497 | optional bool ignore_empty = 8; 498 | } 499 | 500 | // BoolRules describes the constraints applied to `bool` values 501 | message BoolRules { 502 | // Const specifies that this field must be exactly the specified value 503 | optional bool const = 1; 504 | } 505 | 506 | // StringRules describe the constraints applied to `string` values 507 | message StringRules { 508 | // Const specifies that this field must be exactly the specified value 509 | optional string const = 1; 510 | 511 | // Len specifies that this field must be the specified number of 512 | // characters (Unicode code points). Note that the number of 513 | // characters may differ from the number of bytes in the string. 514 | optional uint64 len = 19; 515 | 516 | // MinLen specifies that this field must be the specified number of 517 | // characters (Unicode code points) at a minimum. Note that the number of 518 | // characters may differ from the number of bytes in the string. 519 | optional uint64 min_len = 2; 520 | 521 | // MaxLen specifies that this field must be the specified number of 522 | // characters (Unicode code points) at a maximum. Note that the number of 523 | // characters may differ from the number of bytes in the string. 524 | optional uint64 max_len = 3; 525 | 526 | // LenBytes specifies that this field must be the specified number of bytes 527 | // at a minimum 528 | optional uint64 len_bytes = 20; 529 | 530 | // MinBytes specifies that this field must be the specified number of bytes 531 | // at a minimum 532 | optional uint64 min_bytes = 4; 533 | 534 | // MaxBytes specifies that this field must be the specified number of bytes 535 | // at a maximum 536 | optional uint64 max_bytes = 5; 537 | 538 | // Pattern specifes that this field must match against the specified 539 | // regular expression (RE2 syntax). The included expression should elide 540 | // any delimiters. 541 | optional string pattern = 6; 542 | 543 | // Prefix specifies that this field must have the specified substring at 544 | // the beginning of the string. 545 | optional string prefix = 7; 546 | 547 | // Suffix specifies that this field must have the specified substring at 548 | // the end of the string. 549 | optional string suffix = 8; 550 | 551 | // Contains specifies that this field must have the specified substring 552 | // anywhere in the string. 553 | optional string contains = 9; 554 | 555 | // NotContains specifies that this field cannot have the specified substring 556 | // anywhere in the string. 557 | optional string not_contains = 23; 558 | 559 | // In specifies that this field must be equal to one of the specified 560 | // values 561 | repeated string in = 10; 562 | 563 | // NotIn specifies that this field cannot be equal to one of the specified 564 | // values 565 | repeated string not_in = 11; 566 | 567 | // WellKnown rules provide advanced constraints against common string 568 | // patterns 569 | oneof well_known { 570 | // Email specifies that the field must be a valid email address as 571 | // defined by RFC 5322 572 | bool email = 12; 573 | 574 | // Hostname specifies that the field must be a valid hostname as 575 | // defined by RFC 1034. This constraint does not support 576 | // internationalized domain names (IDNs). 577 | bool hostname = 13; 578 | 579 | // Ip specifies that the field must be a valid IP (v4 or v6) address. 580 | // Valid IPv6 addresses should not include surrounding square brackets. 581 | bool ip = 14; 582 | 583 | // Ipv4 specifies that the field must be a valid IPv4 address. 584 | bool ipv4 = 15; 585 | 586 | // Ipv6 specifies that the field must be a valid IPv6 address. Valid 587 | // IPv6 addresses should not include surrounding square brackets. 588 | bool ipv6 = 16; 589 | 590 | // Uri specifies that the field must be a valid, absolute URI as defined 591 | // by RFC 3986 592 | bool uri = 17; 593 | 594 | // UriRef specifies that the field must be a valid URI as defined by RFC 595 | // 3986 and may be relative or absolute. 596 | bool uri_ref = 18; 597 | 598 | // Address specifies that the field must be either a valid hostname as 599 | // defined by RFC 1034 (which does not support internationalized domain 600 | // names or IDNs), or it can be a valid IP (v4 or v6). 601 | bool address = 21; 602 | 603 | // Uuid specifies that the field must be a valid UUID as defined by 604 | // RFC 4122 605 | bool uuid = 22; 606 | 607 | // WellKnownRegex specifies a common well known pattern defined as a regex. 608 | KnownRegex well_known_regex = 24; 609 | } 610 | 611 | // This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable 612 | // strict header validation. 613 | // By default, this is true, and HTTP header validations are RFC-compliant. 614 | // Setting to false will enable a looser validations that only disallows 615 | // \r\n\0 characters, which can be used to bypass header matching rules. 616 | optional bool strict = 25 [default = true]; 617 | 618 | // IgnoreEmpty specifies that the validation rules of this field should be 619 | // evaluated only if the field is not empty 620 | optional bool ignore_empty = 26; 621 | } 622 | 623 | // WellKnownRegex contain some well-known patterns. 624 | enum KnownRegex { 625 | UNKNOWN = 0; 626 | 627 | // HTTP header name as defined by RFC 7230. 628 | HTTP_HEADER_NAME = 1; 629 | 630 | // HTTP header value as defined by RFC 7230. 631 | HTTP_HEADER_VALUE = 2; 632 | } 633 | 634 | // BytesRules describe the constraints applied to `bytes` values 635 | message BytesRules { 636 | // Const specifies that this field must be exactly the specified value 637 | optional bytes const = 1; 638 | 639 | // Len specifies that this field must be the specified number of bytes 640 | optional uint64 len = 13; 641 | 642 | // MinLen specifies that this field must be the specified number of bytes 643 | // at a minimum 644 | optional uint64 min_len = 2; 645 | 646 | // MaxLen specifies that this field must be the specified number of bytes 647 | // at a maximum 648 | optional uint64 max_len = 3; 649 | 650 | // Pattern specifes that this field must match against the specified 651 | // regular expression (RE2 syntax). The included expression should elide 652 | // any delimiters. 653 | optional string pattern = 4; 654 | 655 | // Prefix specifies that this field must have the specified bytes at the 656 | // beginning of the string. 657 | optional bytes prefix = 5; 658 | 659 | // Suffix specifies that this field must have the specified bytes at the 660 | // end of the string. 661 | optional bytes suffix = 6; 662 | 663 | // Contains specifies that this field must have the specified bytes 664 | // anywhere in the string. 665 | optional bytes contains = 7; 666 | 667 | // In specifies that this field must be equal to one of the specified 668 | // values 669 | repeated bytes in = 8; 670 | 671 | // NotIn specifies that this field cannot be equal to one of the specified 672 | // values 673 | repeated bytes not_in = 9; 674 | 675 | // WellKnown rules provide advanced constraints against common byte 676 | // patterns 677 | oneof well_known { 678 | // Ip specifies that the field must be a valid IP (v4 or v6) address in 679 | // byte format 680 | bool ip = 10; 681 | 682 | // Ipv4 specifies that the field must be a valid IPv4 address in byte 683 | // format 684 | bool ipv4 = 11; 685 | 686 | // Ipv6 specifies that the field must be a valid IPv6 address in byte 687 | // format 688 | bool ipv6 = 12; 689 | } 690 | 691 | // IgnoreEmpty specifies that the validation rules of this field should be 692 | // evaluated only if the field is not empty 693 | optional bool ignore_empty = 14; 694 | } 695 | 696 | // EnumRules describe the constraints applied to enum values 697 | message EnumRules { 698 | // Const specifies that this field must be exactly the specified value 699 | optional int32 const = 1; 700 | 701 | // DefinedOnly specifies that this field must be only one of the defined 702 | // values for this enum, failing on any undefined value. 703 | optional bool defined_only = 2; 704 | 705 | // In specifies that this field must be equal to one of the specified 706 | // values 707 | repeated int32 in = 3; 708 | 709 | // NotIn specifies that this field cannot be equal to one of the specified 710 | // values 711 | repeated int32 not_in = 4; 712 | } 713 | 714 | // MessageRules describe the constraints applied to embedded message values. 715 | // For message-type fields, validation is performed recursively. 716 | message MessageRules { 717 | // Skip specifies that the validation rules of this field should not be 718 | // evaluated 719 | optional bool skip = 1; 720 | 721 | // Required specifies that this field must be set 722 | optional bool required = 2; 723 | } 724 | 725 | // RepeatedRules describe the constraints applied to `repeated` values 726 | message RepeatedRules { 727 | // MinItems specifies that this field must have the specified number of 728 | // items at a minimum 729 | optional uint64 min_items = 1; 730 | 731 | // MaxItems specifies that this field must have the specified number of 732 | // items at a maximum 733 | optional uint64 max_items = 2; 734 | 735 | // Unique specifies that all elements in this field must be unique. This 736 | // constraint is only applicable to scalar and enum types (messages are not 737 | // supported). 738 | optional bool unique = 3; 739 | 740 | // Items specifies the constraints to be applied to each item in the field. 741 | // Repeated message fields will still execute validation against each item 742 | // unless skip is specified here. 743 | optional FieldRules items = 4; 744 | 745 | // IgnoreEmpty specifies that the validation rules of this field should be 746 | // evaluated only if the field is not empty 747 | optional bool ignore_empty = 5; 748 | } 749 | 750 | // MapRules describe the constraints applied to `map` values 751 | message MapRules { 752 | // MinPairs specifies that this field must have the specified number of 753 | // KVs at a minimum 754 | optional uint64 min_pairs = 1; 755 | 756 | // MaxPairs specifies that this field must have the specified number of 757 | // KVs at a maximum 758 | optional uint64 max_pairs = 2; 759 | 760 | // NoSparse specifies values in this field cannot be unset. This only 761 | // applies to map's with message value types. 762 | optional bool no_sparse = 3; 763 | 764 | // Keys specifies the constraints to be applied to each key in the field. 765 | optional FieldRules keys = 4; 766 | 767 | // Values specifies the constraints to be applied to the value of each key 768 | // in the field. Message values will still have their validations evaluated 769 | // unless skip is specified here. 770 | optional FieldRules values = 5; 771 | 772 | // IgnoreEmpty specifies that the validation rules of this field should be 773 | // evaluated only if the field is not empty 774 | optional bool ignore_empty = 6; 775 | } 776 | 777 | // AnyRules describe constraints applied exclusively to the 778 | // `google.protobuf.Any` well-known type 779 | message AnyRules { 780 | // Required specifies that this field must be set 781 | optional bool required = 1; 782 | 783 | // In specifies that this field's `type_url` must be equal to one of the 784 | // specified values. 785 | repeated string in = 2; 786 | 787 | // NotIn specifies that this field's `type_url` must not be equal to any of 788 | // the specified values. 789 | repeated string not_in = 3; 790 | } 791 | 792 | // DurationRules describe the constraints applied exclusively to the 793 | // `google.protobuf.Duration` well-known type 794 | message DurationRules { 795 | // Required specifies that this field must be set 796 | optional bool required = 1; 797 | 798 | // Const specifies that this field must be exactly the specified value 799 | optional google.protobuf.Duration const = 2; 800 | 801 | // Lt specifies that this field must be less than the specified value, 802 | // exclusive 803 | optional google.protobuf.Duration lt = 3; 804 | 805 | // Lt specifies that this field must be less than the specified value, 806 | // inclusive 807 | optional google.protobuf.Duration lte = 4; 808 | 809 | // Gt specifies that this field must be greater than the specified value, 810 | // exclusive 811 | optional google.protobuf.Duration gt = 5; 812 | 813 | // Gte specifies that this field must be greater than the specified value, 814 | // inclusive 815 | optional google.protobuf.Duration gte = 6; 816 | 817 | // In specifies that this field must be equal to one of the specified 818 | // values 819 | repeated google.protobuf.Duration in = 7; 820 | 821 | // NotIn specifies that this field cannot be equal to one of the specified 822 | // values 823 | repeated google.protobuf.Duration not_in = 8; 824 | } 825 | 826 | // TimestampRules describe the constraints applied exclusively to the 827 | // `google.protobuf.Timestamp` well-known type 828 | message TimestampRules { 829 | // Required specifies that this field must be set 830 | optional bool required = 1; 831 | 832 | // Const specifies that this field must be exactly the specified value 833 | optional google.protobuf.Timestamp const = 2; 834 | 835 | // Lt specifies that this field must be less than the specified value, 836 | // exclusive 837 | optional google.protobuf.Timestamp lt = 3; 838 | 839 | // Lte specifies that this field must be less than the specified value, 840 | // inclusive 841 | optional google.protobuf.Timestamp lte = 4; 842 | 843 | // Gt specifies that this field must be greater than the specified value, 844 | // exclusive 845 | optional google.protobuf.Timestamp gt = 5; 846 | 847 | // Gte specifies that this field must be greater than the specified value, 848 | // inclusive 849 | optional google.protobuf.Timestamp gte = 6; 850 | 851 | // LtNow specifies that this must be less than the current time. LtNow 852 | // can only be used with the Within rule. 853 | optional bool lt_now = 7; 854 | 855 | // GtNow specifies that this must be greater than the current time. GtNow 856 | // can only be used with the Within rule. 857 | optional bool gt_now = 8; 858 | 859 | // Within specifies that this field must be within this duration of the 860 | // current time. This constraint can be used alone or with the LtNow and 861 | // GtNow rules. 862 | optional google.protobuf.Duration within = 9; 863 | } 864 | --------------------------------------------------------------------------------