Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Added HTTP Status codes from the RFCs 4918 and 7538 #654

Closed
wants to merge 2 commits into from

Conversation

0xdeafcafe
Copy link
Contributor

These two RFCs are finalized, and rather useful that I feel we should have in the core framework.

7538 RFC Spec
4918 RFC Spec

@dnfclas
Copy link

dnfclas commented Jun 13, 2016

Hi @0xdeafcafe, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

@khellang
Copy link
Contributor

Nice. Submitted 308 for Kestrel as well; aspnet/KestrelHttpServer#925

@Tratcher
Copy link
Member

308 should be fine.

Are you actually using WebDAV? Or are you just adding them for completeness?

@0xdeafcafe
Copy link
Contributor Author

I'm using the unprocessable_entity status code, as it's a good one to use if model validation fails, for instance.

I just added the entire RFC while I was at it for completeness sake. Currently I'm doing this, which I'd rather not (I know I could just extend StatusCodes myself, but I thought I'd just do a pull request instead):

if (!ModelState.IsValid)
    return Json(422 /* unprocessable_entity */, ModelState.ToDictionary());

var question = _lawsContext.Questions.FirstOrDefault(q => q.Id == questionId);
if (question == null)
    return Json(StatusCodes.Status404NotFound, new Error<object>("question_not_found"));

// Verify Module Id is real
var scope = _lawsContext.Scopes.FirstOrDefault(r => r.Id == (Guid) model.ScopeId);
if (scope == null)
    return Json(422 /* unprocessable_entity */, new Error<object>("scope_not_found"));

@Tratcher Tratcher self-assigned this Jun 14, 2016
@Tratcher
Copy link
Member

:shipit:

@Tratcher Tratcher added this to the 1.1.0 milestone Jun 15, 2016
@Tratcher
Copy link
Member

Rebased and merged. Thanks.

@Tratcher Tratcher closed this Jun 15, 2016
@muratg muratg modified the milestones: 1.1.0, 1.0.1 Jun 29, 2016
@xperiandri
Copy link

It would be also nice to have an UnprocessableEntityObjectResult class and UnprocessableEntity() method on Controller

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants