зеркало из https://github.com/Azure/ms-rest-js.git
Add temporary ServiceClient.pipeline() method
This commit is contained in:
Родитель
863f0b11db
Коммит
ad90763a43
|
@ -3,6 +3,7 @@
|
|||
import { DefaultHttpPipelineOptions, HttpPipeline, createDefaultHttpPipeline } from "./httpPipeline";
|
||||
import { HttpRequest } from "./httpRequest";
|
||||
import { HttpResponse } from "./httpResponse";
|
||||
import { WebResource, HttpOperationResponse } from "./msRest";
|
||||
|
||||
/**
|
||||
* Options that can be used to configure a ServiceClient.
|
||||
|
@ -37,6 +38,11 @@ export abstract class ServiceClient {
|
|||
}
|
||||
}
|
||||
|
||||
async pipeline(request: WebResource): Promise<HttpResponse> {
|
||||
const httpRequest: HttpRequest = request.toHttpRequest();
|
||||
return this.sendRequest(httpRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the provided HttpRequest through this ServiceClient's HTTP pipeline.
|
||||
* @param request The HttpRequest to send through this ServiceClient's HTTP pipeline.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import { generateUuid } from "./util/utils";
|
||||
import { Serializer, Mapper } from "./serializer";
|
||||
import { HttpRequest } from "./msRest";
|
||||
export type HttpMethods = "GET" | "PUT" | "POST" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE";
|
||||
|
||||
/**
|
||||
|
@ -33,6 +34,15 @@ export class WebResource {
|
|||
this.formData = undefined;
|
||||
}
|
||||
|
||||
public toHttpRequest(): HttpRequest {
|
||||
return new HttpRequest({
|
||||
method: this.method,
|
||||
url: this.url,
|
||||
headers: this.headers,
|
||||
body: this.body
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the required properties such as method, url, headers["Content-Type"],
|
||||
* headers["accept-language"] are defined. It will throw an error if one of the above
|
||||
|
@ -305,4 +315,4 @@ export interface RequestOptionsBase {
|
|||
*/
|
||||
customHeaders?: { [key: string]: string };
|
||||
[key: string]: any;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче