This repository demos different ways to implement REST clients for service-to-service communication. See my blog post for detailed information.
The following implementations are demoed:
- Creating a REST client using
Flurl. Manuallycreating a REST client.- Generating a REST client using
NSwag. - Creating a REST client using
Refit. - Creating a REST client using
RestEase. - Creating a rest client using
RestSharp.
You can open the solution in visual studio and run it, this will do the following:
- Start the
RestClientExamples.ExampleApi. - Start the
RestClientExamples.Cli.- The
Cliwill prompt you to select an option:- Demo making HTTP calls to the
ExampleApiusing the different types of clients. - Execute a performance test using the different types of clients.
- Demo making HTTP calls to the
- The
Inside the RestClientExamples solution you will find the following:
Contains a simple command line demo on how to use the clients.
Contains an ExampleApi with the default WeatherForecastController.
Contains the Models used by the ExampleApi.
Shows how you can use Flurl to make HTTP requests.
Shows how you can manually create a REST client using typed clients.
Shows how you can leverage NSwag to automatically generate REST clients based on an openapi specification.
Shows how you can leverage Refit to generate a REST client using an interface.
Shows how you can use RestEase to generate a REST client using an interface.
Shows how you can use RestSharp to make HTTP requests.