Skip to content

Commit

Permalink
feat:add validate field ext and protobuf message validator
Browse files Browse the repository at this point in the history
  • Loading branch information
geebytes committed Jul 31, 2024
1 parent becf9ae commit e6cd4f0
Show file tree
Hide file tree
Showing 63 changed files with 2,787 additions and 1,049 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
version: "22.2"
- name: Install protoc-gen-grpc-gateway
run: |
git clone https://github.com/geebytes/grpc-gateway.git
git clone --recursive https://github.com/geebytes/grpc-gateway.git
cd grpc-gateway
go install ./protoc-gen-grpc-gateway
- name: Test
Expand Down
10 changes: 10 additions & 0 deletions cmd/begonia/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,14 @@ func main() {
if err := cmd.Execute(); err != nil {
log.Fatalf("failed to start begonia: %v", err)
}
// env, _ := cmd.Flags().GetString("env")
// cnf, err := cmd.Flags().GetString("config")
// if err != nil {
// log.Fatalf("failed to get config: %v", err)
// }
// config := config.ReadConfigWithDir("dev", "/data/work/begonia-org/begonia/config/settings.yml")
// worker := internal.New(config, gateway.Log, "127.0.0.1:12138")
// hd, _ := os.UserHomeDir()
// _ = os.WriteFile(hd+"/.begonia/gateway.json", []byte(fmt.Sprintf(`{"addr":"http://%s"}`, "127.0.0.1:12138")), 0666)
// worker.Start()
}
13 changes: 7 additions & 6 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ file:
engines:
- name: "FILE_ENGINE_MINIO"
endpoint: "127.0.0.1:9000"
accessKey: "7OdVJK1alV8cpRMeBLBW"
secretKey: "2GNNRqqElReC1KnV3kX9jSjyLU4kwOaTZEqDS2vH"
accessKey: "rLV2Jjj2UbMWSJOhTOtZ"
secretKey: "OVyJOILwx4iVE0EVJB4CKB65j7xlhjT5q1aGCv5t"
- name: "FILE_ENGINE_LOCAL"
endpoint: "/data/work/begonia-org/begonia/upload"
protos:
Expand Down Expand Up @@ -70,11 +70,12 @@ gateway:
- "example.com"
plugins:
local:
logger: 1
exception: 0
# 优先级越大越先执行
exception: 4
logger: 3
http: 2
params_validator: 3
auth: 4
auth: 1
params_validator: 0
# only_api_key_auth: 4
rpc:
# - server:
Expand Down
299 changes: 0 additions & 299 deletions gateway.json

This file was deleted.

4 changes: 3 additions & 1 deletion gateway/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gateway

import (
"context"
"fmt"
"strings"

loadbalance "github.com/begonia-org/go-loadbalancer"
Expand Down Expand Up @@ -42,7 +43,7 @@ func (e *httpForwardGrpcEndpointImpl) Request(req GrpcRequest) (proto.Message, r
return nil, runtime.ServerMetadata{
HeaderMD: make(map[string][]string),
TrailerMD: make(map[string][]string),
}, err
}, fmt.Errorf("get conn error:%v", err)
}
defer e.pool.Release(req.GetContext(), cc)

Expand All @@ -51,6 +52,7 @@ func (e *httpForwardGrpcEndpointImpl) Request(req GrpcRequest) (proto.Message, r
in := req.GetIn()
ctx := req.GetContext()
err = conn.Invoke(ctx, req.GetFullMethodName(), in, out, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
// log.Printf("request %s out:%v",req.GetFullMethodName(), out.ProtoReflect().Type().Descriptor().FullName())
return out, metadata, err

}
Expand Down
Loading

0 comments on commit e6cd4f0

Please sign in to comment.