Feign 1.5.3

dotnet add package Feign --version 1.5.3
                    
NuGet\Install-Package Feign -Version 1.5.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Feign" Version="1.5.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Feign" Version="1.5.3" />
                    
Directory.Packages.props
<PackageReference Include="Feign" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Feign --version 1.5.3
                    
#r "nuget: Feign, 1.5.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Feign&version=1.5.3
                    
Install Feign as a Cake Addin
#tool nuget:?package=Feign&version=1.5.3
                    
Install Feign as a Cake Tool

Usage

  1. Install the NuGet package

    PM> Install-Package Feign

  2. Define services :

    [FeignClient("test-service", UriKind = UriKind.RelativeOrAbsolute)]
    [Headers("Cache-Control:max-age=0")]
    [RequestMapping("/api/test")]
    public interface ITestService
    {
        string Name { get; set; }
        /// <summary>
        /// async get
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Headers("Cache-Control:max-age=0", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36")]
        [RequestMapping("/{id}", Method = "GET")]
        //[GetMapping("/{id}")]
        [MethodId("GetAsync")]
        Task<string> GetAsync([PathVariable("id")] int id, [RequestQuery] string name);
        /// <summary>
        /// get Stream
        /// </summary>
        /// <returns></returns>
        [GetMapping("stream")]
        Task<Stream> GetStreamAsync();
        /// <summary>
        /// get buffer
        /// </summary>
        /// <param name="authorization">sample: scheme parameter</param>
        /// <param name="header">sample: name:value</param>
        /// <returns></returns>
        [GetMapping("stream")]
        Task<byte[]> GetBufferAsync([RequestAuthorization] string authorization, [RequestHeader] string header);
        /// <summary>
        /// get HttpResponseMessage
        /// </summary>
        /// <returns></returns>
        [GetMapping("stream")]
        Task<HttpResponseMessage> GetHttpResponseMessageAsync();

        /// <summary>
        /// post a json request
        /// </summary>
        /// <param name="id"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        [RequestMapping("{id}", Method = "POST")]
        //[PostMapping("/{id}")]
        string PostJson([PathVariable] int id, [RequestBody] TestServiceParam param);

        /// <summary>
        /// post a form request
        /// </summary>
        /// <param name="id"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        [RequestMapping("{id}", Method = "POST")]
        //[PostMapping("/{id}")]
        string PostForm(int id, [RequestForm] TestServiceParam param);

        /// <summary>
        /// upload 2 files
        /// </summary>
        /// <param name="file1"></param>
        /// <param name="file2"></param>
        /// <returns></returns>
        [PostMapping("/api/test/upload")]
        string UploadFile(IHttpRequestFile file1, IHttpRequestFile file2);

        /// <summary>
        /// upload multiple files
        /// </summary>
        /// <param name="file1"></param>
        /// <param name="file2"></param>
        /// <returns></returns>
        [PostMapping("/api/test/upload")]
        string UploadFile(IHttpRequestFileForm files);

    }
  1. Install the NuGet package on .net core application

    PM> Install-Package Feign.DependencyInjection

        var feignBuilder = builder.Services.AddFeignClients(options =>
        {
            //options.DiscoverServiceCacheTime = TimeSpan.FromSeconds(10);
        }).AddFeignClients(typeof(ITestService).Assembly, FeignClientLifetime.Singleton)
        .ConfigureJsonSettings(options =>
        {
            options.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull;
            options.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
        });
    
  2. Use service discovery, here is Steeltoe as an example

    PM> Install-Package Feign.Steeltoe

        feignBuilder.AddSteeltoe();
    
  3. Using services, here we take asp.net core as an example


    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET api/values/5
        [HttpGet("{id}")]
        public async Task<ActionResult<object>> Get(int id, [FromServices] ITestService testService)
        {
            await testService.GetAsync(id);
	        testService.PostJson(id, new TestServiceParam());
            testService.UploadFile(
                new FilePathHttpRequestFile(@"E:\asdasdasd.txt"),
                new FilePathHttpRequestFile(@"E:\asdasdasd.txt")
            );
            return "ok";
        }
    }

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Feign:

Package Downloads
Feign.DependencyInjection

feign for Microsoft.Extensions.DependencyInjection

Feign.Steeltoe

feign Steeltoe Component

Feign.Polly

feign Polly Component

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.3 304 1/6/2025
1.5.3-beta6 107 12/23/2024
1.5.3-beta4 100 12/19/2024
1.5.3-beta3 92 11/26/2024
1.5.3-beta2 89 10/31/2024
1.5.3-beta1 90 9/27/2024
1.5.2 475 3/4/2024
1.5.1 501 11/28/2023
1.5.1-beta1 162 10/31/2023
1.4.1 727 11/4/2022
1.3.5-preview3 169 11/4/2022
1.3.5-preview2 149 11/3/2022
1.3.5-preview1 159 11/2/2022
1.3.4 778 8/24/2022
1.3.1 745 6/1/2022
1.3.0.1-preview3 202 5/23/2022
1.3.0.1-beta1 371 5/21/2022
1.2.5.7-beta1 204 5/17/2022
1.2.5.6 493 12/18/2021
1.2.5.5-preview6 284 11/10/2021
1.2.5.5-preview5 278 8/28/2021
1.2.5.5-preview1 491 5/28/2021
1.2.5.4 1,713 12/16/2020
1.2.5.2 503 11/6/2020
1.2.5.1 1,168 5/22/2020
1.2.5 601 4/5/2020
1.2.4 574 3/18/2020
1.2.3.1 576 3/16/2020
1.2.2 23,465 12/20/2019
1.2.1.7 1,483 10/3/2019
1.2.1.6 615 9/26/2019
1.2.1.5 604 9/26/2019
1.2.1.4 621 9/26/2019
1.2.1.3 596 9/24/2019
1.2.1.2 822 9/24/2019
1.2.1.1 1,023 9/3/2019
1.2.1 745 9/3/2019