Skip to content

honorduan/DHaven.Faux

 
 

Repository files navigation

DHaven.Faux

Lobby 3g77q1gu23cbsfu3?svg=true nuget package blue

NetFlix created a bunch of really useful cloud projects, all of which are Java based. Steeltoe OSS has made service discovery and a few other integrations available to the Dotnet community. One glaring missing feature is an analog for Feign. This library intends to fill that gap. I’m only one guy, so I appreciate any help I can get.

What will DHaven.Faux do?

Given an interface to a web service with all the Mvc attributes decorating the methods, DHaven.Faux will generate an implementation that calls the web service for you. It will even use Steeltoe.Discovery.Client to resolve the service for you.

Even better, this will be integrated with Microsoft’s Dependency Injection framework so that you only have to add your interface, and Faux will generate the implementation.

The following interface:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Fortune_Teller_UI.Services
{
    [FauxClient("fortuneService")]
    [Route("api/fortunes")]
    public interface IFortuneService
    {
        // GET api/fortunes
        [HttpGet]
        Task<IEnumerable<Fortune>> Get();

        // GET api/fortunes/random
        [HttpGet("random")]
        public Fortune Random();
    }
}

Will have all the plumbing done for you so that you can use the service just like a standard CSharp object. (Appologies to Steeltoe, I adapted their starter example)

What does DHaven.Faux do right now?

The foundation is laid to support all the attributes defined in the project. If something isn’t working, please write up an issue. Feel free to contribute.

Note
it is important that the objects you use in your interface are objects that NewtonSoft.JSon knows how to serialize.

Generated Classes

If you want to enable looking at the generated source code for your implementation, you will need to add the following to your appsettings.json file:

{
  "faux": {
    "debug": {
      "outputSource": true,
      "sourcePath": "./faux-generated"
    }
  }
}
  • outputSource: true to write the generated classes to the file system

  • sourcePath: path to the directory you want the generated classes placed

To prevent naming conflicts between your parameters and internal Faux code, all Faux variables are prefixed with the Kanji 仮 (kari). Kari is word that means "temporary". When it’s used as a prefix it also means "fake". It seemed fitting to use that particular character with English to represent internal variables in this project.

Contributing

Please add issues if there any problems, questions, or feature requests.

We need the CLA to protect the project and to protect you from legal implications. Feel free to fork, make changes, and provide pull requests.

About

Dotnet version of the Netflix Feign library

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%