@@ -212,8 +212,7 @@ func (a *anydoc) List(ctx context.Context, plat platform.PlatformType, optFuncs
212212 if err != nil {
213213 return nil , err
214214 }
215- u .Path = p .ListURL ()
216- var contentType string
215+ u .Path = p .PathPrefix () + "/list"
217216
218217 var body io.Reader
219218 switch p .ListMethod () {
@@ -286,19 +285,23 @@ func (a *anydoc) List(ctx context.Context, plat platform.PlatformType, optFuncs
286285 return nil , err
287286 }
288287
289- req .Header ["X-Trace-ID" ] = trace .TraceID (ctx )
290-
291- if contentType != "" {
292- req .Header .Set ("Content-Type" , contentType )
288+ if req .Method == http .MethodPost {
289+ req .Header .Set ("Content-Type" , "application/json" )
293290 }
294291
292+ req .Header ["X-Trace-ID" ] = trace .TraceID (ctx )
293+
295294 resp , err := util .HTTPClient .Do (req )
296295 if err != nil {
297296 return nil , err
298297 }
299298
300299 defer resp .Body .Close ()
301300
301+ if resp .StatusCode != http .StatusOK {
302+ return nil , fmt .Errorf ("anydoc list failed, status code: %d" , resp .StatusCode )
303+ }
304+
302305 var (
303306 docRes anydocRes [struct {
304307 Docs * tree.Node [ListDoc ] `json:"docs"`
@@ -317,9 +320,6 @@ func (a *anydoc) List(ctx context.Context, plat platform.PlatformType, optFuncs
317320 return nil , err
318321 }
319322
320- if resp .StatusCode != http .StatusOK {
321- return nil , fmt .Errorf ("anydoc list status code: %d" , resp .StatusCode )
322- }
323323 res .Docs = docRes .Data .Docs
324324
325325 return & res , nil
@@ -353,7 +353,7 @@ func (a *anydoc) Export(ctx context.Context, platform platform.PlatformType, id
353353 return "" , err
354354 }
355355
356- req , err := http .NewRequestWithContext (ctx , http .MethodPost , fmt .Sprintf ("%s%s" , a .address , p .ExportURL () ), bytes .NewReader (reqBodyBytes ))
356+ req , err := http .NewRequestWithContext (ctx , http .MethodPost , fmt .Sprintf ("%s%s" , a .address , p .PathPrefix () + "/export" ), bytes .NewReader (reqBodyBytes ))
357357 if err != nil {
358358 return "" , err
359359 }
@@ -367,6 +367,10 @@ func (a *anydoc) Export(ctx context.Context, platform platform.PlatformType, id
367367
368368 defer resp .Body .Close ()
369369
370+ if resp .StatusCode != http .StatusOK {
371+ return "" , fmt .Errorf ("anydoc export status code: %d" , resp .StatusCode )
372+ }
373+
370374 var res anydocRes [string ]
371375 err = json .NewDecoder (resp .Body ).Decode (& res )
372376 if err != nil {
@@ -378,10 +382,6 @@ func (a *anydoc) Export(ctx context.Context, platform platform.PlatformType, id
378382 return "" , err
379383 }
380384
381- if resp .StatusCode != http .StatusOK {
382- return "" , fmt .Errorf ("anydoc export status code: %d" , resp .StatusCode )
383- }
384-
385385 return res .Data , nil
386386}
387387
@@ -395,7 +395,7 @@ func (a *anydoc) AuthURL(ctx context.Context, plat platform.PlatformType, reqDat
395395 if err != nil {
396396 return "" , err
397397 }
398- req , err := http .NewRequestWithContext (ctx , http .MethodPost , fmt .Sprintf ("%s%s" , a .address , p .AuthURL () ), bytes .NewReader (reqBytes ))
398+ req , err := http .NewRequestWithContext (ctx , http .MethodPost , fmt .Sprintf ("%s%s" , a .address , p .PathPrefix () + "/auth_url" ), bytes .NewReader (reqBytes ))
399399 if err != nil {
400400 return "" , err
401401 }
@@ -435,7 +435,7 @@ func (a *anydoc) UserInfo(ctx context.Context, plat platform.PlatformType, reqDa
435435 if err != nil {
436436 return nil , err
437437 }
438- req , err := http .NewRequestWithContext (ctx , http .MethodPost , fmt .Sprintf ("%s%s" , a .address , p .UserInfoURL () ), bytes .NewReader (reqBytes ))
438+ req , err := http .NewRequestWithContext (ctx , http .MethodPost , fmt .Sprintf ("%s%s" , a .address , p .PathPrefix () + "/user" ), bytes .NewReader (reqBytes ))
439439 if err != nil {
440440 return nil , err
441441 }
0 commit comments