blob: 2c8f482ff5d2343004363c2cefbd406f8c47f964 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package wiki
import (
"errors"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (s *server) WikiFindPage(request *gitalypb.WikiFindPageRequest, stream gitalypb.WikiService_WikiFindPageServer) error {
ctx := stream.Context()
if err := validateWikiFindPage(request); err != nil {
return status.Errorf(codes.InvalidArgument, "WikiFindPage: %v", err)
}
client, err := s.ruby.WikiServiceClient(ctx)
if err != nil {
return err
}
clientCtx, err := rubyserver.SetHeaders(ctx, s.locator, request.GetRepository())
if err != nil {
return err
}
rubyStream, err := client.WikiFindPage(clientCtx, request)
if err != nil {
return err
}
return rubyserver.Proxy(func() error {
resp, err := rubyStream.Recv()
if err != nil {
md := rubyStream.Trailer()
stream.SetTrailer(md)
return err
}
return stream.Send(resp)
})
}
func validateWikiFindPage(request *gitalypb.WikiFindPageRequest) error {
if err := git.ValidateRevisionAllowEmpty(request.Revision); err != nil {
return err
}
if len(request.GetTitle()) == 0 {
return errors.New("empty Title")
}
return nil
}
|