github.com/opensearch-project/opensearch-go/v2@v2.3.0/opensearchapi/opensearchapi.request.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // 3 // The OpenSearch Contributors require contributions made to 4 // this file be licensed under the Apache-2.0 license or a 5 // compatible open source license. 6 // 7 // Modifications Copyright OpenSearch Contributors. See 8 // GitHub history for details. 9 10 // Licensed to Elasticsearch B.V. under one or more contributor 11 // license agreements. See the NOTICE file distributed with 12 // this work for additional information regarding copyright 13 // ownership. Elasticsearch B.V. licenses this file to you under 14 // the Apache License, Version 2.0 (the "License"); you may 15 // not use this file except in compliance with the License. 16 // You may obtain a copy of the License at 17 // 18 // http://www.apache.org/licenses/LICENSE-2.0 19 // 20 // Unless required by applicable law or agreed to in writing, 21 // software distributed under the License is distributed on an 22 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 23 // KIND, either express or implied. See the License for the 24 // specific language governing permissions and limitations 25 // under the License. 26 27 package opensearchapi 28 29 import ( 30 "context" 31 "io" 32 "net/http" 33 ) 34 35 const ( 36 headerContentType = "Content-Type" 37 ) 38 39 var ( 40 headerContentTypeJSON = []string{"application/json"} 41 ) 42 43 // Request defines the API request. 44 // 45 type Request interface { 46 Do(ctx context.Context, transport Transport) (*Response, error) 47 } 48 49 // newRequest creates an HTTP request. 50 // 51 func newRequest(method, path string, body io.Reader) (*http.Request, error) { 52 return http.NewRequest(method, path, body) 53 }