pinsvcapi: fix some basic bugs
This commit is contained in:
parent
333b933cd3
commit
ab33ec668c
|
@ -25,7 +25,7 @@ func init() {
|
|||
// occurs. It implements the error interface.
|
||||
type APIError struct {
|
||||
Reason string `json:"reason"`
|
||||
Details string `json:"string"`
|
||||
Details string `json:"details"`
|
||||
}
|
||||
|
||||
func (apiErr APIError) Error() string {
|
||||
|
@ -180,13 +180,16 @@ type ListOptions struct {
|
|||
}
|
||||
|
||||
func (lo *ListOptions) FromQuery(q url.Values) error {
|
||||
for _, cstr := range strings.Split(q.Get("cid"), ",") {
|
||||
cidq := q.Get("cid")
|
||||
if len(cidq) > 0 {
|
||||
for _, cstr := range strings.Split(cidq, ",") {
|
||||
c, err := cid.Decode(cstr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error decoding cid %s: %w", cstr, err)
|
||||
}
|
||||
lo.Cids = append(lo.Cids, c)
|
||||
}
|
||||
}
|
||||
|
||||
lo.Name = q.Get("name")
|
||||
lo.Match = MatchFromString(q.Get("match"))
|
||||
|
|
|
@ -109,9 +109,8 @@ func globalPinInfoToSvcPinStatus(
|
|||
|
||||
status.Info = map[string]string{
|
||||
"source": "IPFS cluster API",
|
||||
"warning1": "disregard created time",
|
||||
"warning2": "CID used for requestID. Conflicts possible",
|
||||
"warning3": "experimental",
|
||||
"warning1": "CID used for requestID. Conflicts possible",
|
||||
"warning2": "experimental",
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
@ -144,6 +143,12 @@ func NewAPIWithHost(ctx context.Context, cfg *Config, h host.Host) (*API, error)
|
|||
func (api *API) routes(c *rpc.Client) []common.Route {
|
||||
api.rpcClient = c
|
||||
return []common.Route{
|
||||
{
|
||||
Name: "ListPins",
|
||||
Method: "GET",
|
||||
Pattern: "/pins",
|
||||
HandlerFunc: api.listPins,
|
||||
},
|
||||
{
|
||||
Name: "AddPin",
|
||||
Method: "POST",
|
||||
|
@ -168,12 +173,6 @@ func (api *API) routes(c *rpc.Client) []common.Route {
|
|||
Pattern: "/pins/{requestID}",
|
||||
HandlerFunc: api.removePin,
|
||||
},
|
||||
{
|
||||
Name: "ListPins",
|
||||
Method: "GET",
|
||||
Pattern: "/pins",
|
||||
HandlerFunc: api.listPins,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +350,7 @@ func (api *API) listPins(w http.ResponseWriter, r *http.Request) {
|
|||
"",
|
||||
"Cluster",
|
||||
"StatusAll",
|
||||
opts.Status,
|
||||
tst,
|
||||
&globalPinInfos,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user