Skip to content

Commit 4061c06

Browse files
add new snippet (dotnet#68)
1 parent 839b3d4 commit 4061c06

File tree

1 file changed

+21
-2
lines changed
  • fundamentals/middleware/problem-details-service

1 file changed

+21
-2
lines changed

fundamentals/middleware/problem-details-service/Program.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define API_CONTROLLER // MIDDLEWARE API_CONTROLLER API_CONT_SHORT DEFAULT
1+
#define DISABLE // MIDDLEWARE API_CONTROLLER API_CONT_SHORT DEFAULT DISABLE
22
#if NEVER
33
#elif MIDDLEWARE
44
// <snippet_middleware>
@@ -169,7 +169,6 @@ await problemDetailsService.WriteAsync(new ProblemDetailsContext
169169

170170
app.Run();
171171
// </snippet_default>
172-
173172
#elif MIN_API
174173
// <snippet_min_api>
175174
var builder = WebApplication.CreateBuilder(args);
@@ -245,4 +244,24 @@ await problemDetailsService.WriteAsync(new ProblemDetailsContext
245244

246245
app.Run();
247246
// </snippet_min_api>
247+
#elif DISABLE
248+
// <snippet_disable>
249+
var builder = WebApplication.CreateBuilder(args);
250+
251+
builder.Services.AddControllers()
252+
.ConfigureApiBehaviorOptions(options =>
253+
{
254+
options.SuppressMapClientErrors = true;
255+
});
256+
257+
var app = builder.Build();
258+
259+
app.UseHttpsRedirection();
260+
261+
app.UseAuthorization();
262+
263+
app.MapControllers();
264+
265+
app.Run();
266+
// </snippet_disable>
248267
#endif

0 commit comments

Comments
 (0)