Add temporary ServiceClient.pipeline() method

This commit is contained in:
Dan Schulte 2018-05-03 13:31:20 -07:00
Родитель 863f0b11db
Коммит ad90763a43
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -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;
}
}