diff --git a/Rest.Net/Extensions/HttpListenerRequestExtensions.cs b/Rest.Net/HttpListenerRequestExtensions.cs similarity index 100% rename from Rest.Net/Extensions/HttpListenerRequestExtensions.cs rename to Rest.Net/HttpListenerRequestExtensions.cs diff --git a/Rest.Net/Extensions/HttpListenerResponseExtensions.cs b/Rest.Net/HttpListenerResponseExtensions.cs similarity index 81% rename from Rest.Net/Extensions/HttpListenerResponseExtensions.cs rename to Rest.Net/HttpListenerResponseExtensions.cs index da50c7c..1e15cbe 100644 --- a/Rest.Net/Extensions/HttpListenerResponseExtensions.cs +++ b/Rest.Net/HttpListenerResponseExtensions.cs @@ -225,5 +225,46 @@ namespace MontoyaTech.Rest.Net return response; } } + + /// + /// Sets the response to bad request with a text message saying the request was null or empty. + /// + /// + /// + public static HttpListenerResponse BadRequestNull(this HttpListenerResponse response) + { + return response.WithStatus(HttpStatusCode.BadRequest).WithText("Request was null or empty."); + } + + /// + /// Sets the response to a bad request with a text message saying the request was invalid. + /// + /// + /// + public static HttpListenerResponse BadRequestInvalid(this HttpListenerResponse response) + { + return response.WithStatus(HttpStatusCode.BadRequest).WithText("Request data was invalid."); + } + + /// + /// Sets the response to a bad request with a text message saying the request was out of range. + /// + /// + /// + public static HttpListenerResponse BadRequestOutOfRange(this HttpListenerResponse response) + { + return response.WithStatus(HttpStatusCode.BadRequest).WithText("Request data was out of range"); + } + + /// + /// Sets the response to a bad request with a text message saying a field in the request was out of range. + /// + /// + /// + /// + public static HttpListenerResponse BadRequestOutOfRange(this HttpListenerResponse response, string fieldName) + { + return response.WithStatus(HttpStatusCode.BadRequest).WithText($"{fieldName} in request is out of range."); + } } } diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index bea601d..aefd13a 100644 --- a/Rest.Net/Rest.Net.csproj +++ b/Rest.Net/Rest.Net.csproj @@ -17,7 +17,7 @@ MontoyaTech.Rest.Net MontoyaTech.Rest.Net True - 1.1.6 + 1.1.7 Logo_Symbol_Black_Outline.png diff --git a/Rest.Net/Extensions/StringExtensions.cs b/Rest.Net/StringExtensions.cs similarity index 100% rename from Rest.Net/Extensions/StringExtensions.cs rename to Rest.Net/StringExtensions.cs