From bdbfe432f9291d97459e7de45dfffa5897af5956 Mon Sep 17 00:00:00 2001 From: Jakubozga Date: Mon, 12 Dec 2016 11:28:07 +0100 Subject: [PATCH] Added static method MethodNotAllowed in JsonApiException --- JSONAPI/Documents/Builders/JsonApiException.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/JSONAPI/Documents/Builders/JsonApiException.cs b/JSONAPI/Documents/Builders/JsonApiException.cs index 00472ea0..4b72176c 100644 --- a/JSONAPI/Documents/Builders/JsonApiException.cs +++ b/JSONAPI/Documents/Builders/JsonApiException.cs @@ -99,5 +99,20 @@ public static JsonApiException CreateForForbidden(string detail = null) }; return new JsonApiException(error); } + + /// + /// Creates a JsonApiException to send a 405 Method Not Allowed error. + /// + public static JsonApiException CreateForMethodNotAllowed(string detail = null) + { + var error = new Error + { + Id = Guid.NewGuid().ToString(), + Status = HttpStatusCode.MethodNotAllowed, + Title = "Method not allowed", + Detail = detail + }; + return new JsonApiException(error); + } } }