/
aprogrammer
/
reverse-proxy-ms-yarp
Обзор
Документация
Войти
/
aprogrammer
/
reverse-proxy-ms-yarp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/ReverseProxy/Transforms/HttpMethodTransformExtensions.cs
34 строки
1 KB
Kahbazi
File Scoped Namespaces (#1352)
12 ноя 2021, 21:53
Не верифицирован
12 ноя 2021, 21:53
44f13d9
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Yarp.ReverseProxy.Configuration; using Yarp.ReverseProxy.Transforms.Builder; namespace Yarp.ReverseProxy.Transforms; /// <summary> /// Extensions for modifying the request method. /// </summary> public static class HttpMethodTransformExtensions { /// <summary> /// Clones the route and adds the transform that will replace the HTTP method if it matches. /// </summary> public static RouteConfig WithTransformHttpMethodChange(this RouteConfig route, string fromHttpMethod, string toHttpMethod) { return route.WithTransform(transform => { transform[HttpMethodTransformFactory.HttpMethodChangeKey] = fromHttpMethod; transform[HttpMethodTransformFactory.SetKey] = toHttpMethod; }); } /// <summary> /// Adds the transform that will replace the HTTP method if it matches. /// </summary> public static TransformBuilderContext AddHttpMethodChange(this TransformBuilderContext context, string fromHttpMethod, string toHttpMethod) { context.RequestTransforms.Add(new HttpMethodChangeTransform(fromHttpMethod, toHttpMethod)); return context; } }