dotnet / dotnet/aspnetcore

Add ServiceUnavailable and ServiceUnavailable<T> to TypedResults

Open
#61,705 1 comment 2 reactions 0 assignees View on GitHub
area-minimal
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

## Summary

TypedResults provides an excellent way to provide strongly typed web APIs. However, it is currently missing built-in types for the standard ServiceUnavailable 503 error. It would be useful if this was included.

## Motivation and goals

I suspect the reasoning for this not being added is that if a service is unavailable, the .NET code will not be executing and thus unable to return a 503 result.

The scenario I frequently encounter is where the service being called depends on another service for some requests. In this case, if the dependent service is unavailable, it is logical to return a 503 result.

## Alternative

Currently, as a workaround, I use StatusCodeHttpResult instead.

## Implementation

This would mirror the approach taken to add InternalServerError in #53073.

Notably, in that issue, @halter73 raised the point that ServiceUnavailable may in fact be more useful than InternalServerError. Suggesting other people would find this addition useful.

Contributor guide

Open the contributing guide

Research direction

Start with the implementation and tests for InternalServerError referenced in issue #53073, then trace the corresponding TypedResults APIs. Add ServiceUnavailable and ServiceUnavailable consistently with that approach, and verify the existing TypedResults test coverage includes both 503 result types.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.