Skip to content

Commit

Permalink
Add custom marshaler to handle different views
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Nov 10, 2023
1 parent f2a6afc commit aa36cc2
Show file tree
Hide file tree
Showing 4 changed files with 966 additions and 316 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ debug:

# Generate the protobuf/gRPC code
proto:
@go run ./util/openapi2proto/main.go ./tes/task-execution-schemas/openapi/task_execution_service.openapi.yaml > tes/tes.proto
@cd tes && protoc \
$(PROTO_INC) \
--go_out ./ \
Expand Down
28 changes: 15 additions & 13 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/encoding/protojson"

"github.com/golang/gddo/httputil"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
Expand Down Expand Up @@ -83,18 +82,21 @@ func (s *Server) Serve(pctx context.Context) error {

// Set up HTTP proxy of gRPC API
mux := http.NewServeMux()
// mar := runtime.JSONBuiltin{}
// grpcMux := runtime.NewServeMux(runtime.WithMarshalerOption("*/*", &mar))
m := protojson.MarshalOptions{
Indent: " ",
EmitUnpopulated: false,
UseProtoNames: true,
}
u := protojson.UnmarshalOptions{}
grpcMux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{
MarshalOptions: m,
UnmarshalOptions: u,
}))

marsh := NewMarshaler()

Check failure on line 86 in server/server.go

View workflow job for this annotation

GitHub Actions / build

undefined: NewMarshaler

Check failure on line 86 in server/server.go

View workflow job for this annotation

GitHub Actions / lint

undefined: NewMarshaler (typecheck)

Check failure on line 86 in server/server.go

View workflow job for this annotation

GitHub Actions / build

undefined: NewMarshaler

Check failure on line 86 in server/server.go

View workflow job for this annotation

GitHub Actions / unitTest

undefined: NewMarshaler
grpcMux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, marsh))

// m := protojson.MarshalOptions{
// Indent: " ",
// EmitUnpopulated: true,
// UseProtoNames: true,
// }
// u := protojson.UnmarshalOptions{}
// grpcMux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{
// MarshalOptions: m,
// UnmarshalOptions: u,
// }))

//runtime.OtherErrorHandler = s.handleError //TODO: Review effects

dashmux := http.NewServeMux()
Expand Down
Loading

0 comments on commit aa36cc2

Please sign in to comment.