Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
128 stars 47 forks source link

Make callHttp accept one options object argument #435

Closed hossam-nasr closed 1 year ago

hossam-nasr commented 1 year ago

Following the lead of #415 and #429, this PR also switches the context.df.callHttp() on orchestration contexts from using explicit arguments to using one options argument for all parameters, following the lead of popular frameworks like axios

Before (actual sample from our docs here):

const restartResponse = yield context.df.callHttp(
        "POST",
        `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.Compute/virtualMachines/${vmName}/restart?api-version=${apiVersion}`,
        undefined, // no request content
        undefined, // no request headers (besides auth which is handled by the token source)
        tokenSource
);

After:

const restartResponse = yield context.df.callHttp({
        method: "POST",
        url: `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.Compute/virtualMachines/${vmName}/restart?api-version=${apiVersion}`,
        tokenSource,
});

Changes that were made in this PR:

If there are other (breaking) changes we want to make to the callHttp API, now is the time to call them out. For example: