Ejemplo n.º 1
0
        private ReverseProxyContext GetProxyContext(HttpContext context, ReverseProxyConfigModel config)
        {
            var ctx = new ReverseProxyContext();

            ctx.Query              = context.Request.Query;
            ctx.RequestUrl         = string.Concat(context.Request.Scheme, "://", context.Request.Host, context.Request.Path, context.Request.QueryString.Value);
            ctx.Cookies            = context.Request.Cookies;
            ctx.HttpMethod         = context.Request.Method;
            ctx.InputStream        = context.Request.Body;
            ctx.RequestContentType = context.Request.ContentType;
            ctx.ReverseConfig      = config;
            foreach (string k in context.Request.Headers.Keys)
            {
                ctx.Headers.Add(k, context.Request.Headers[k]);
            }
            return(ctx);
        }
Ejemplo n.º 2
0
 public ReverseProxyMiddleware(RequestDelegate next, IServiceProvider svp, IOptions <ReverseProxyConfigModel> config)
 {
     this._svp = svp;
     this.ReverseProxyConfig = config?.Value;
     this.next = next;
 }