Files
gitea/routers/api/bots/grpc.go
2022-11-25 17:48:44 +08:00

33 lines
877 B
Go

// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package bots
import (
"code.gitea.io/gitea/modules/web"
"gitea.com/gitea/proto-go/ping/v1/pingv1connect"
"github.com/bufbuild/connect-go"
grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
)
func grpcServiceRoute(r *web.Route) {
compress1KB := connect.WithCompressMinBytes(1024)
// grpcV1
grpcPath, gHandler := grpcreflect.NewHandlerV1(
grpcreflect.NewStaticReflector(pingv1connect.PingServiceName),
compress1KB,
)
// grpcV1Alpha
grpcAlphaPath, gAlphaHandler := grpcreflect.NewHandlerV1Alpha(
grpcreflect.NewStaticReflector(pingv1connect.PingServiceName),
compress1KB,
)
r.Post(grpcPath+"{name}", grpcHandler(gHandler))
r.Post(grpcAlphaPath+"{name}", grpcHandler(gAlphaHandler))
}