forgejo/routers/api/actions/ping/ping.go
Earl Warren ec7dc193b4 chore: use code.forgejo.org/forgejo/actions-proto (#9981)
instead of code.gitea.io/actions-proto-go

It is a hard fork of code.gitea.io/actions-proto-go which has been used by the runner in the past few months.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9981
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-11-05 16:10:52 +01:00

38 lines
955 B
Go

// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package ping
import (
"context"
"fmt"
"net/http"
"forgejo.org/modules/log"
pingv1 "code.forgejo.org/forgejo/actions-proto/ping/v1"
"code.forgejo.org/forgejo/actions-proto/ping/v1/pingv1connect"
"connectrpc.com/connect"
)
func NewPingServiceHandler() (string, http.Handler) {
return pingv1connect.NewPingServiceHandler(&Service{})
}
var _ pingv1connect.PingServiceHandler = (*Service)(nil)
type Service struct {
pingv1connect.UnimplementedPingServiceHandler
}
func (s *Service) Ping(
ctx context.Context,
req *connect.Request[pingv1.PingRequest],
) (*connect.Response[pingv1.PingResponse], error) {
log.Trace("Content-Type: %s", req.Header().Get("Content-Type"))
log.Trace("User-Agent: %s", req.Header().Get("User-Agent"))
res := connect.NewResponse(&pingv1.PingResponse{
Data: fmt.Sprintf("Hello, %s!", req.Msg.Data),
})
return res, nil
}