You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ping.go 955B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package ping
  4. import (
  5. "context"
  6. "fmt"
  7. "net/http"
  8. "code.gitea.io/gitea/modules/log"
  9. pingv1 "code.gitea.io/actions-proto-go/ping/v1"
  10. "code.gitea.io/actions-proto-go/ping/v1/pingv1connect"
  11. "github.com/bufbuild/connect-go"
  12. )
  13. func NewPingServiceHandler() (string, http.Handler) {
  14. return pingv1connect.NewPingServiceHandler(&Service{})
  15. }
  16. var _ pingv1connect.PingServiceHandler = (*Service)(nil)
  17. type Service struct {
  18. pingv1connect.UnimplementedPingServiceHandler
  19. }
  20. func (s *Service) Ping(
  21. ctx context.Context,
  22. req *connect.Request[pingv1.PingRequest],
  23. ) (*connect.Response[pingv1.PingResponse], error) {
  24. log.Trace("Content-Type: %s", req.Header().Get("Content-Type"))
  25. log.Trace("User-Agent: %s", req.Header().Get("User-Agent"))
  26. res := connect.NewResponse(&pingv1.PingResponse{
  27. Data: fmt.Sprintf("Hello, %s!", req.Msg.Data),
  28. })
  29. return res, nil
  30. }