Package Description
$ dotnet add package Mhlabs.WebApi.JsendActionFilterAction filter for optionally wrapping a response in JSend format.
See https://labs.omniti.com/labs/jsend.
To enable, add the filter as middleware.
services.AddMvc(s =>
{
s.AddJSendResponseFormat();
});
Example usage:
[HttpGet]
public ActionResult<bool> GetIt(string id, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(id))
{
return this.Error("NO_ID", "Didn't get it.");
}
return true;
}
[HttpGet]
public async Task<DtoObject> Get(string id, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(id))
{
this.Fail("INVALID_ID", "Id is invalid");
}
var dto = await _handler.GetObject(id, cancellationToken);
if (dto == null)
{
this.Fail("NOT_FOUND");
}
return dto;
}
Set the Version number in the <a href="https://github.com/mhlabs/Mhlabs.WebApi.JsendActionFilter/blob/master/Mhlabs.WebApi.JsendActionFilter/Mhlabs.WebApi.JsendActionFilter.csproj"> .csproj-file</a> before pushing. If an existing version is pushed the <a href="https://github.com/mhlabs/Mhlabs.WebApi.JsendActionFilter/actions">build will fail</a>.
Version number and add -beta postfix (can have .1, .2 etc. at the end)