MCPcopy
hub / github.com/perkeep/perkeep / GetSignerPaths

Method GetSignerPaths

pkg/search/handler.go:879–917  ·  view source on GitHub ↗

GetSignerPaths returns paths with a target of req.Target.

(req *SignerPathsRequest)

Source from the content-addressed store, hash-verified

877
878// GetSignerPaths returns paths with a target of req.Target.
879func (h *Handler) GetSignerPaths(req *SignerPathsRequest) (*SignerPathsResponse, error) {
880 ctx := context.TODO()
881 if !req.Signer.Valid() {
882 return nil, errors.New("error getting signer paths: nil signer")
883 }
884 if !req.Target.Valid() {
885 return nil, errors.New("error getting signer paths: nil target")
886 }
887 h.index.RLock()
888 defer h.index.RUnlock()
889
890 paths, err := h.index.PathsOfSignerTarget(ctx, req.Signer, req.Target)
891 if err != nil {
892 return nil, fmt.Errorf("Error getting paths of %s: %v", req.Target.String(), err)
893 }
894 var jpaths []*SignerPathsItem
895 for _, path := range paths {
896 jpaths = append(jpaths, &SignerPathsItem{
897 ClaimRef: path.Claim,
898 BaseRef: path.Base,
899 Suffix: path.Suffix,
900 })
901 }
902
903 dr := h.NewDescribeRequest()
904 for _, path := range paths {
905 dr.StartDescribe(ctx, path.Base, 2)
906 }
907 metaMap, err := dr.metaMap()
908 if err != nil {
909 return nil, err
910 }
911
912 res := &SignerPathsResponse{
913 Paths: jpaths,
914 Meta: metaMap,
915 }
916 return res, nil
917}
918
919func (h *Handler) serveSignerPaths(rw http.ResponseWriter, req *http.Request) {
920 defer httputil.RecoverJSON(rw, req)

Callers 1

serveSignerPathsMethod · 0.95

Calls 8

NewDescribeRequestMethod · 0.95
StartDescribeMethod · 0.95
metaMapMethod · 0.95
RLockMethod · 0.65
RUnlockMethod · 0.65
PathsOfSignerTargetMethod · 0.65
ValidMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected