Open Closed

How we can extend Dynamic API Client Proxy to allow changing RemoteService base url dynamically ? #3224


User avatar
0
krashhh created

Hi,

I want to use Dynamic API Client Proxy, but I need an option to change the base URL in runtime before specific service API call.

public class MyService : ITransientDependency
{
    private readonly IHttpClientProxy<IBookAppService> _bookService;

    public MyService(IHttpClientProxy<IBookAppService> bookHttpClientProxy)
    {
        _bookHttpClientProxy = bookHttpClientProxy;
    }

    public async Task DoIt()
    {
       ** _bookHttpClientProxy.BaseURL = "xyz";     // Something like this.**
        var books = await _bookHttpClientProxy.Service.GetListAsync();
        foreach (var book in books)
        {
            Console.WriteLine($"[BOOK {book.Id}] Name={book.Name}");
        }
    }
}

Please help me how I can extend something to achieve this functionality?


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can change the AbpRemoteServiceOptions. And use AddAbpDynamicOptions<AbpRemoteServiceOptions>

    https://github.com/abpframework/abp/pull/6332

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09