-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ProblemDetails Title #126
Comments
I agree with your intention. The trick is, how to implement it. The methods in question are private and don't accept a title argument. If they did, it would break their usage in public ResultStatusOptions With(Type responseType, Func<ControllerBase, IResult, object> getResponseObject)
{
ResponseType = responseType;
GetResponseObject = getResponseObject;
return this;
} Even if it accepted a title, there's not currently a way to pass one into the public ResultStatusMap AddDefaultMap()
{
return For(ResultStatus.Ok, HttpStatusCode.OK)
.For(ResultStatus.Error, (HttpStatusCode)422, resultStatusOptions => resultStatusOptions
.With(UnprocessableEntity))
.For(ResultStatus.Forbidden, HttpStatusCode.Forbidden)
.For(ResultStatus.Unauthorized, HttpStatusCode.Unauthorized)
.For(ResultStatus.Invalid, HttpStatusCode.BadRequest, resultStatusOptions => resultStatusOptions
.With(BadRequest))
.For(ResultStatus.NotFound, HttpStatusCode.NotFound, resultStatusOptions => resultStatusOptions
.With(NotFoundEntity))
.For(ResultStatus.Conflict, HttpStatusCode.Conflict, resultStatusOptions => resultStatusOptions
.With(ConflictEntity))
.For(ResultStatus.CriticalError, HttpStatusCode.InternalServerError, resultStatusOptions =>
resultStatusOptions
.With(CriticalEntity))
.For(ResultStatus.Unavailable, HttpStatusCode.ServiceUnavailable, resultStatusOptions =>
resultStatusOptions
.With(UnavailableEntity))
.For(ResultStatus.NoContent, HttpStatusCode.NoContent);
} I could parameterize return For(ResultStatus.Ok, HttpStatusCode.OK)
.For(ResultStatus.Error, (HttpStatusCode)422, resultStatusOptions => resultStatusOptions
.With(UnprocessableEntity, "Not processable"))
... But that doesn't really help anything because it's still a hard-coded string inside my library. Maybe my library could look for something in configuration, and use that if it's present? I'm open to implementation suggestions. |
Currently, the title of the ProblemDetails Result, is hardcoded.
e.g.,
Result/src/Ardalis.Result.AspNetCore/ResultStatusMap.cs
Line 123 in 6384038
This does not allow internationalization and makes the content pretty generic. However, according to the RFC standard, localization is intended and the message provided in the example is pretty specific.
https://www.rfc-editor.org/rfc/rfc7807
First, I thought of having titles in multiple languages in ardalis.result, but now I think the best approach would be to allow the developer using ardalis.result to set the title. Any thoughts?
The text was updated successfully, but these errors were encountered: