GetSignerPaths returns paths with a target of req.Target.
(req *SignerPathsRequest)
| 877 | |
| 878 | // GetSignerPaths returns paths with a target of req.Target. |
| 879 | func (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 | |
| 919 | func (h *Handler) serveSignerPaths(rw http.ResponseWriter, req *http.Request) { |
| 920 | defer httputil.RecoverJSON(rw, req) |
no test coverage detected