Files
search-go/task_documents.go
Matt Van HornandJavad Rajabzadeh 0278e6e135 refactor: merge executeNDJSONRequest into executeRequest and validate accepted content-type
Per @ElyarSadig's review:

- Remove executeNDJSONRequest. NDJSON streaming is now handled inside
  executeRequest when req.acceptedContentType is set to NDJSON and
  req.withResponse is non-nil.
- Add acceptedContentType field on internalRequest (peer to acceptedStatusCodes)
  and validate the response Content-Type header against it. Mismatch
  returns a typed error.
- Add Decoder(io.Reader) (streamDecoder, error) method on the encoder
  interface so callers can stream-decode without bypassing the encoder
  abstraction.
- GetTaskDocumentsWithContext is now a thin wrapper that delegates to
  executeRequest with acceptedContentType set.
2026-05-29 17:40:35 +00:00

27 lines
780 B
Go

package meilisearch
import (
"context"
"net/http"
"strconv"
)
func (m *meilisearch) GetTaskDocuments(taskUID int64, dst interface{}) error {
return m.GetTaskDocumentsWithContext(context.Background(), taskUID, dst)
}
func (m *meilisearch) GetTaskDocumentsWithContext(ctx context.Context, taskUID int64, dst interface{}) error {
req := &internalRequest{
endpoint: "/tasks/" + strconv.FormatInt(taskUID, 10) + "/documents",
method: http.MethodGet,
withRequest: nil,
withResponse: dst,
withQueryParams: nil,
withResponseEncoding: true,
acceptedStatusCodes: []int{http.StatusOK},
acceptedContentType: contentTypeNDJSON,
functionName: "GetTaskDocuments",
}
return m.client.executeRequest(ctx, req)
}