Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
431 stars 184 forks source link

Remove HttpStatusCode=OK from WriteAsJsonAsync #2720

Closed RohitRanjanMS closed 1 month ago

RohitRanjanMS commented 1 month ago

Eliminated the default value for HttpStatusCode and removed the overloaded methods for setting HttpStatusCode in the response.

Default Behavior - 200 OK

var responseData = req.CreateResponse();
await responseData.WriteAsJsonAsync(new { message = "Done" });
return responseData;

Return a non-200 response

var responseData = req.CreateResponse(HttpStatusCode.BadRequest);
await responseData.WriteAsJsonAsync(new { message = "An error occurred" });
return responseData;

resolves #776

This is a breaking change, targeting feature/2.x branch.

Pull request checklist