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 as a Cake Addin
#tool nuget:?package=Feign&version=1.5.3
                    
Install 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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 334 1/6/2025
1.5.3-beta6 115 12/23/2024
1.5.3-beta4 106 12/19/2024
1.5.3-beta3 103 11/26/2024
1.5.3-beta2 96 10/31/2024
1.5.3-beta1 99 9/27/2024
1.5.2 508 3/4/2024
1.5.1 516 11/28/2023
1.5.1-beta1 170 10/31/2023
1.4.1 748 11/4/2022
1.3.5-preview3 189 11/4/2022
1.3.5-preview2 169 11/3/2022
1.3.5-preview1 190 11/2/2022
1.3.4 799 8/24/2022
1.3.1 769 6/1/2022
1.3.0.1-preview3 226 5/23/2022
1.3.0.1-beta1 464 5/21/2022
1.2.5.7-beta1 226 5/17/2022
1.2.5.6 524 12/18/2021
1.2.5.5-preview6 309 11/10/2021
1.2.5.5-preview5 304 8/28/2021
1.2.5.5-preview1 538 5/28/2021
1.2.5.4 1,750 12/16/2020
1.2.5.2 536 11/6/2020
1.2.5.1 1,203 5/22/2020
1.2.5 636 4/5/2020
1.2.4 609 3/18/2020
1.2.3.1 612 3/16/2020
1.2.2 23,623 12/20/2019
1.2.1.7 1,531 10/3/2019
1.2.1.6 654 9/26/2019
1.2.1.5 641 9/26/2019
1.2.1.4 658 9/26/2019
1.2.1.3 637 9/24/2019
1.2.1.2 861 9/24/2019
1.2.1.1 1,064 9/3/2019
1.2.1 781 9/3/2019