mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-22 08:34:05 +09:00
chore(proto): Add ping service
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@ -5,42 +5,12 @@
|
||||
package bots
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
v1 "gitea.com/gitea/proto/gen/proto/v1"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
)
|
||||
|
||||
type RunnerService struct{}
|
||||
|
||||
func (s *RunnerService) Connect(
|
||||
ctx context.Context,
|
||||
req *connect.Request[v1.ConnectRequest],
|
||||
) (*connect.Response[v1.ConnectResponse], error) {
|
||||
log.Info("Request headers: %v", req.Header())
|
||||
res := connect.NewResponse(&v1.ConnectResponse{
|
||||
JobId: 100,
|
||||
})
|
||||
res.Header().Set("Gitea-Version", "v1")
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *RunnerService) Accept(
|
||||
ctx context.Context,
|
||||
req *connect.Request[v1.AcceptRequest],
|
||||
) (*connect.Response[v1.AcceptResponse], error) {
|
||||
log.Info("Request headers: %v", req.Header())
|
||||
res := connect.NewResponse(&v1.AcceptResponse{
|
||||
JobId: 100,
|
||||
})
|
||||
res.Header().Set("Gitea-Version", "v1")
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func giteaHandler(h http.Handler) http.HandlerFunc {
|
||||
func grpcHandler(h http.Handler) http.HandlerFunc {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("Got connection: %v", r.Proto)
|
||||
h.ServeHTTP(w, r)
|
||||
|
Reference in New Issue
Block a user