Creating a proxy to another web api with Asp.net core

后端 未结 8 875
走了就别回头了
走了就别回头了 2020-11-29 19:39

I\'m developing an ASP.Net Core web application where I need to create a kind of \"authentication proxy\" to another (external) web service.

What I mean by authentic

8条回答
  •  再見小時候
    2020-11-29 19:52

    If anyone is interested, I took the Microsoft.AspNetCore.Proxy code and made it a little better with middleware.

    Check it out here: https://github.com/twitchax/AspNetCore.Proxy. NuGet here: https://www.nuget.org/packages/AspNetCore.Proxy/. Microsoft archived the other one mentioned in this post, and I plan on responding to any issues on this project.

    Basically, it makes reverse proxying another web server a lot easier by allowing you to use attributes on methods that take a route with args and compute the proxied address.

    [ProxyRoute("api/searchgoogle/{query}")]
    public static Task SearchGoogleProxy(string query)
    {
        // Get the proxied address.
        return Task.FromResult($"https://www.google.com/search?q={query}");
    }
    

提交回复
热议问题