mirror of
https://github.com/hanzoai/search-go.git
synced 2026-10-30 18:22:58 +00:00
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.
27 lines
780 B
Go
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)
|
|
}
|