/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Mvc/test/WebSites/BasicWebSite/RequestIdMiddleware.cs
29 строк
830 B
Shreyas Jejurkar
chore : Remove unwanted `using` statement (#39176)
02 янв 2022, 17:39
Не верифицирован
02 янв 2022, 17:39
c85baf8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace BasicWebSite; // Initializes a scoped-service with a request Id from a header public class RequestIdMiddleware { private readonly RequestDelegate _next; public RequestIdMiddleware(RequestDelegate next) { _next = next; } public Task Invoke(HttpContext context) { var requestIdService = context.RequestServices.GetService<RequestIdService>(); if (requestIdService.RequestId != null) { throw new InvalidOperationException("RequestId should be null here"); } var requestId = context.Request.Headers.RequestId; requestIdService.RequestId = requestId; return _next(context); } }