Skip to content

Cleanup code #27

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

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Azure.WebJobs.Extensions.HttpApi.Core
{
internal class LocalStaticAppResult : IActionResult
public class LocalStaticAppResult : IActionResult
{
public string DefaultFile { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/Azure.WebJobs.Extensions.HttpApi/Core/ProxyResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Azure.WebJobs.Extensions.HttpApi.Core
{
internal class ProxyResult : IActionResult
public class ProxyResult : IActionResult
{
public ProxyResult(string backendUri)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Azure.WebJobs.Extensions.HttpApi.Core
{
internal class RemoteStaticAppResult : ProxyResult
public class RemoteStaticAppResult : ProxyResult
{
public RemoteStaticAppResult(string backendUri)
: base(backendUri)
Expand Down
30 changes: 15 additions & 15 deletions src/Azure.WebJobs.Extensions.HttpApi/HttpFunctionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,26 @@ protected ObjectResult Problem(string detail = null, string instance = null, int
{
var problemDetails = ProblemDetailsFactory.CreateProblemDetails(HttpContext, statusCode ?? 500, title, type, detail, instance);

return new ObjectResult(problemDetails) { StatusCode = problemDetails.Status };
return new(problemDetails) { StatusCode = problemDetails.Status };
}

protected ActionResult ValidationProblem(ValidationProblemDetails descriptor)
protected BadRequestObjectResult ValidationProblem(ValidationProblemDetails descriptor)
{
if (descriptor is null)
{
throw new ArgumentNullException(nameof(descriptor));
}

return new BadRequestObjectResult(descriptor);
return new(descriptor);
}

protected ActionResult ValidationProblem(ModelStateDictionary modelState) => ValidationProblem(modelStateDictionary: modelState);
protected ObjectResult ValidationProblem(ModelStateDictionary modelState) => ValidationProblem(modelStateDictionary: modelState);

protected ObjectResult ValidationProblem(string detail = null, string instance = null, int? statusCode = null, string title = null, string type = null, ModelStateDictionary modelStateDictionary = null)
{
var validationProblem = ProblemDetailsFactory.CreateValidationProblemDetails(HttpContext, modelStateDictionary ?? ModelState, statusCode, title, type, detail, instance);

return new ObjectResult(validationProblem) { StatusCode = validationProblem.Status };
return new(validationProblem) { StatusCode = validationProblem.Status };
}

protected CreatedResult Created(string uri, object value)
Expand All @@ -158,7 +158,7 @@ protected CreatedResult Created(string uri, object value)
throw new ArgumentNullException(nameof(uri));
}

return new CreatedResult(uri, value);
return new(uri, value);
}

protected CreatedResult Created(Uri uri, object value)
Expand All @@ -168,7 +168,7 @@ protected CreatedResult Created(Uri uri, object value)
throw new ArgumentNullException(nameof(uri));
}

return new CreatedResult(uri, value);
return new(uri, value);
}

protected CreatedResult CreatedAtFunction(string functionName) => CreatedAtFunction(functionName, null, null);
Expand All @@ -187,7 +187,7 @@ protected AcceptedResult Accepted(Uri uri)
throw new ArgumentNullException(nameof(uri));
}

return new AcceptedResult(uri, null);
return new(uri, null);
}

protected AcceptedResult Accepted(string uri) => new(uri, null);
Expand All @@ -199,7 +199,7 @@ protected AcceptedResult Accepted(Uri uri, object value)
throw new ArgumentNullException(nameof(uri));
}

return new AcceptedResult(uri, value);
return new(uri, value);
}

protected AcceptedResult Accepted(string uri, object value) => new(uri, value);
Expand All @@ -213,29 +213,29 @@ protected AcceptedResult AcceptedAtFunction(string functionName, object routeVal
protected StatusCodeResult Forbid() => StatusCode(StatusCodes.Status403Forbidden);
protected ObjectResult Forbid(object value) => StatusCode(StatusCodes.Status403Forbidden, value);

protected IActionResult Proxy(string backendUri, Action<HttpRequestMessage> beforeSend = null, Action<HttpResponseMessage> afterSend = null)
protected ProxyResult Proxy(string backendUri, Action<HttpRequestMessage> beforeSend = null, Action<HttpResponseMessage> afterSend = null)
{
if (backendUri is null)
{
throw new ArgumentNullException(nameof(backendUri));
}

return new ProxyResult(backendUri) { BeforeSend = beforeSend, AfterSend = afterSend };
return new(backendUri) { BeforeSend = beforeSend, AfterSend = afterSend };
}

protected IActionResult RemoteStaticApp(string backendUri, string fallbackExclude = null)
protected RemoteStaticAppResult RemoteStaticApp(string backendUri, string fallbackExclude = null)
{
if (backendUri is null)
{
throw new ArgumentNullException(nameof(backendUri));
}

return new RemoteStaticAppResult(backendUri) { FallbackExclude = fallbackExclude };
return new(backendUri) { FallbackExclude = fallbackExclude };
}

protected IActionResult LocalStaticApp(string defaultFile = "index.html", string fallbackPath = "404.html", string fallbackExclude = null)
protected LocalStaticAppResult LocalStaticApp(string defaultFile = "index.html", string fallbackPath = "404.html", string fallbackExclude = null)
{
return new LocalStaticAppResult { DefaultFile = defaultFile, FallbackPath = fallbackPath, FallbackExclude = fallbackExclude };
return new() { DefaultFile = defaultFile, FallbackPath = fallbackPath, FallbackExclude = fallbackExclude };
}

#endregion
Expand Down