Add new endpoint and improve exception handling
Removed the `asByte` parameter from XML documentation in `DocumentController.cs`, indicating the method no longer supports byte array returns. Added a new HTTP POST endpoint `CloseAsync` in `WorkflowsController.cs`, which is currently not implemented and throws a `NotImplementedException`. Enhanced `ExceptionHandlingMiddleware.cs` to handle `NotImplementedException` by logging a warning and returning a `501 Not Implemented` response in a problem details format.
This commit is contained in:
@@ -18,7 +18,6 @@ public sealed class DocumentController(ISender sender) : ControllerBase
|
|||||||
/// <param name="id">Document identifier.</param>
|
/// <param name="id">Document identifier.</param>
|
||||||
/// <param name="userId">User identifier.</param>
|
/// <param name="userId">User identifier.</param>
|
||||||
/// <param name="processId">Process identifier.</param>
|
/// <param name="processId">Process identifier.</param>
|
||||||
/// <param name="asByte">Return document as byte array.</param>
|
|
||||||
/// <param name="cancellationToken">Cancellation token.</param>
|
/// <param name="cancellationToken">Cancellation token.</param>
|
||||||
/// <returns>Document response envelope grouped by source.</returns>
|
/// <returns>Document response envelope grouped by source.</returns>
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("{id:int}")]
|
||||||
|
|||||||
@@ -27,4 +27,20 @@ public sealed class WorkflowsController(ISender sender) : ControllerBase
|
|||||||
{
|
{
|
||||||
return Ok(await sender.Send(new GetWorkflowsQuery(wisagId), cancellationToken));
|
return Ok(await sender.Send(new GetWorkflowsQuery(wisagId), cancellationToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wisagId"></param>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="processId"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
[HttpPost("{wisagId:int}/{source}/{processId:long}/closing")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status501NotImplemented)]
|
||||||
|
public Task<ActionResult<JsonElement>> CloseAsync([FromRoute] int wisagId, [FromRoute] string source, [FromRoute] long processId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,22 @@ public sealed class ExceptionHandlingMiddleware(RequestDelegate next, ILogger<Ex
|
|||||||
context.Response.ContentType = "application/problem+json";
|
context.Response.ContentType = "application/problem+json";
|
||||||
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
|
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
|
||||||
}
|
}
|
||||||
|
catch (NotImplementedException ex)
|
||||||
|
{
|
||||||
|
logger.LogWarning(ex, "Not implemented: {Method} {Path}",
|
||||||
|
context.Request.Method, context.Request.Path);
|
||||||
|
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
type = "https://tools.ietf.org/html/rfc7807",
|
||||||
|
title = "Not Implemented",
|
||||||
|
status = StatusCodes.Status501NotImplemented
|
||||||
|
};
|
||||||
|
|
||||||
|
context.Response.StatusCode = StatusCodes.Status501NotImplemented;
|
||||||
|
context.Response.ContentType = "application/problem+json";
|
||||||
|
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex, "Unhandled exception for {Method} {Path}",
|
logger.LogError(ex, "Unhandled exception for {Method} {Path}",
|
||||||
|
|||||||
Reference in New Issue
Block a user