Last active
May 12, 2020 16:32
-
-
Save Tratcher/f54397545dc9776bb0c0c7e7f902ec35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/microsoft/reverse-proxy/issues/60 | |
https://github.com/microsoft/reverse-proxy/issues/21 | |
Request | |
Request Parameters Transform - Applied before building the HttpRequestMessage | |
RequestParamtersTransformContext | |
- HttpContext | |
- Method | |
- Version? Or should that be controled by the destination? | |
- PathBase | |
- Path | |
- Query | |
- Exclude scheme and host/authority, those are set by the destination | |
RequestParametersTransform.Transform(UrlTransformContext context) - abstract/custom/base | |
PathStringTransformation:RequestParamtersTransformContext | |
- Value PathString (or path template that supports route values?) | |
- Prepend/Append/Set/RemoveStart/RemoveEnd Enum | |
- TransformPathBase/Path bool | |
PathTemplateTransformation:RequestParamtersTransformContext | |
- Value string route template (supports route values?) | |
- Replaces whole path | |
- TransformPathBase/Path bool (?) | |
QueryStringTransformation:RequestParamtersTransformContext - Use QueryStringHelpers.Append | |
- Value string | |
- Prepend/Append/Set Enum | |
- Transform(UrlTransformationContext) | |
Headers | |
- We don't want to change HttpRequest.Headers, nor do we want to deal with the split issue of HttpRequestMessage/Content.Headers. | |
- Idealy we'd transform headers as we copied from one object model to the other (if we are copying headers, that's a seperate flag). | |
- foreach header in Request.Headers | |
- Look up any transformations for this header, run them. | |
- Set result on HttpRequestMessage/Content | |
- Record header as transformed (hashset) | |
- foreach transformation in transformations | |
- If Key was not already transformed, run transformations | |
HeaderTransform | |
- Key - header name string | |
- Transform(HttpContext, existingValues, out newValues) | |
HeaderValueTransform : HeaderTransform | |
- Values StringValues | |
- Enum Append, AppendCSV, Set, etc... | |
Trailers - Same as headers, different collection | |
// Do we need this? Should this be done as HttpClient middleware instead? | |
// Things that can't be transformed in other ways: Properties, Body | |
RequestTransformation.Transform(HttpRequestMessage) | |
BodyTransform - MUST be custom middleware, out of scope | |
Response | |
// Do we need this? Should this be done as HttpClient or AspNetCore middleware instead? | |
// I would be nice to apply transforms before the response body started. HttpClient middleware can do that, | |
// but it's harder for AspNetCore middleware because you have to intercept the response body. | |
ResponseTransformation.Transform(HttpResponse) - Not HttpResponseMessage(?) | |
HeadersTransform - Same as request, applied during the copy loop | |
- Conditionally applied? | |
Trailers - Same as headers, different collection | |
- Conditionally applied? | |
BodyTransform - MUST be custom middleware, out of scope | |
# Initial feature | |
- Three collections | |
- Request Parameters transforms | |
- Request header transforms | |
- Request trailers transforms (not currently supported) | |
- Response header transforms | |
- Response trailers transforms | |
# Nginx comparisons | |
- NGinx has a path regex based rewrite option: https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#rewrite. This isn't part of pxoy request transformation, it's generic middleware. | |
- proxy_pass url/backend - if the backend defines a path base then it replaces the route matched path. Includes support for variaibles, which replace the original path. | |
- proxy_http_version - defaults to 1.0 | |
- proxy_method (can contain variables) | |
- proxy_pass_request_headers - enables/disables forwarding all request headers | |
- proxy_set_header - set request header. Remove by setting empty. append/prepend using variables. sets Host to the destination host by default. | |
- proxy_hide_header - strip response header value. Has several defined by default. proxy_pass_header allows defaults to be sent | |
- add_header/trailer - add response header (not proxy specific) - Only for specific status codes unless marked as 'always' | |
- proxy_cookie_domain/path - response Set-Cookie domain/path transformations | |
- proxy_redirect - response Location header prefix substitution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment